Jump to content

View more

Image of the Day

Adding some finishing touches...
Follow us for more
#screenshotsaturday #indiedev... by #MakeGoodGames https://t.co/Otbwywbm3a
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

problem with rotational dynamics

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
No replies to this topic

#1 Irlan Robson   Members   

4059
Like
0Likes
Like

Posted 10 February 2013 - 07:25 PM

Hi everyone. I'm doing my class project and i'm having troubles with Euler integration (witch seems to be the basic)...
The main loop:
 
 
        torque = position.cross(force);
        
        momentum += dt * force;
        //velocity = momentum * (1.0f / mass);
 
        position += velocity * dt;
 
        ang_momentum += torque * dt;
        m_inertia_inverse = MakeMatrixFromQuaternion(orientation).transpose() * g_inertia * MakeMatrixFromQuaternion(orientation);
        ang_vel = multvm(ang_momentum, m_inertia_inverse); //multiplies a vector by a matrix
 
        orientation += (Quaternion(0, ang_vel.x, ang_vel.y, ang_vel.z) * orientation) * (0.5f * dt);
        orientation.normalize();

 

"g_inertia" is the following matrix3

 

Ix = Iy = Iz = 0.4f * mass * Mathematics::sqrt(radius);
 
        inertia.m11 = Ix;            inertia.m12 = 0;        inertia.m13 = 0;
        inertia.m21 = 0;            inertia.m22 = Iy;        inertia.m23 = 0;

        inertia.m31 = 0;            inertia.m32 = 0;        inertia.m33 = Iz; 

 

and i'm rotating like this:

 

 

orientation.angleAxis(angle, axis); //quaternion to angle axis
    
        glTranslatef(position.x, position.y, position.z);
        glRotatef( angle / Mathematics::pi * 180.0f, axis.x, axis.y, axis.z );

 

Is the code right? i've spend 5 days trying to solve it but i think is a little problem and i can't see

Seems like i'm having trouble with the numbers... they are large, especially with the angular velocity...






Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.