Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Calculating direction of angular velocity?

This topic is 5283 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hmm, I just can't figure this one out... basically, I calculate my angular velocity doing Torque's Magnitude/Moment of Inertia but there is a problem... it doesn't tell you whether this angular velocity is clockwise or counterclockwise! I came up with an idea on how to solve this - let's assume our force is made of two points: A (point at which interacts) and B (point A + magnitude, end of the force). Now if I draw a line from body's center of mass to A, then if B is to the right, it'll rotate clockwise, otherwise, counterclockwise (and of course, if B is on the line, it wont rotate at all). However, I found calcuating this really tricky... so how do I determine if a point is to the left or right of a line! Also, keep in mind that if the point goes "below center of mass" then the direction of rotation flips: if our CenterOfMass - A line goes straight up then if point B is to the right and above CM, it'll rotate clockwise, but if it is below CM - counterclockwise... so how do you determine that? or is there a better way to determine the direction of angular velocity??? EDIT: I'm speaking 2D here... EDIT2: THe only thing I came up with, is to rotate points A and B around the CM so that A is directly above CM. Then, checking this is quite easy... [edited by - Koobazaur on June 3, 2004 3:03:27 AM]

Share this post

Link to post
Share on other sites
so, you have torques and moment, translating into angular velocity, translating into an orientation, or angle of the object. You should not have to worry about that at all. It''s just a standard integration.

void CBody::Update(float dt)
m_xPosition += m_xVelocity * dt;
m_fOrientation += m_fAngVelocity * dt;

m_xVelocity += m_xNetForce * (m_fInvMass * dt);
m_fAngVelocity += m_fNetTorque * (m_fInvInertia * dt);

m_xNetForce = Vector(0.0f, 0.0f);
m_fNetTorque = 0.0f;

void CBody::AddForce(const Vector& F, const Vector& P)
m_xNetForce += F;
m_fNetTorque += (P - m_xPosition) ^ F;

''^'' is a vector cross product. in 2D, it returns a float

inline float operator^(const Vector &V) const { return (x * V.y) - (y * V.x); }

if you don''t undestand what I''m talking about, I suggest you read Chris Hecker''s physics articles.

you can see a demo of that stuff here.

(or at http://uk.geocities.com/olivier_rebellion/ "2D box contact calculations" if the link is broken).

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!