How do I calculate angular velocity/speed

0 favourites
  • 5 posts
From the Asset Store
Have you ever dreamed of playing in a Speedball game or tournament?
  • I wonder if this (see picture) would work without using physics behavior (revolute joint).

    But I do not know how to calculate the angular velocity/speed of the object if it is hit by a projectile or hits a static platform.

    Thanks

  • I wonder if this (see picture) would work without using physics behavior (revolute joint).

    But I do not know how to calculate the angular velocity/speed of the object if it is hit by a projectile or hits a static platform.

    Thanks

    Why you don't want to use physics behaviour? It's a lot easier than doing yourself the things that physics behaviour done by default.

  • Agreed it's better using the physics because it does a lot for you, but it never hurts to lean something new.

    The formula that correlates velocity to angular velocity is:

    displacement x velocity = angular_velocity

    Where "displacement" is a vector from the pivot to the point of collision and "x" is a vector cross product. "w" will be in radians/sec so we'll need to convert it to degrees/sec by multiplying by 180/pi.

    (displacement x velocity)*180/pi = angular_velocity

    So to finish it up the displacement vector can be calculated with:

    dispX = collisionX - pivotX

    dispY = collisionY - pivotY

    Also a 2d vector cross product can be defined as:

    v1 x v2 = v1x*v2y - v1y*v2x

    So them combining those you get a lovely formula like this:

    ((collisionX - pivotX)*vy - (collisionY - pivotY)*vx)*180/pi = angular_velocity

    "vx" and "vy" are the x and y components of velocity. Depending on the behavior used you can also get vx and vy from speed and angle_of_motion:

    vx = speed * cos(angle_of_motion)

    vy = speed * sin(angle_of_motion)

    So to use the formula you could make a collision event when a bullet collides with sprite, and use the bullet's position for collisionX and collisionY.

    Now all we have is a way to convert linear motion to angular but it's not enough for it to look realistic. For that you'll need to use momentum and kinetic energy to calculate a collision response. There's info on it elsewhere but the formulas get kind of lengthy and really it's one of the main reasons it's much easier to use an existing physics engine.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Agreed it's better using the physics because it does a lot for you, but it never hurts to lean something new...

    I agree with the physics part.

    but I was interested to learn how it works, and if you could apply it to the platform behavior somehow

    Thanks for the formula, really interesting.

    I did setup the machine (in the picture above) with physics. I have two disk setup with revolute joint one for wheel and one with revolute joint to the box above. When the box is tilted like this \ the machine moves forward but when it is tilted like this / it's slowing down. Is this behavior to be expected, and how can I get it to keep the same speed even if it is tilted like / that.

  • I'd have to see a capx as I don't know from your description.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)