Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Rotating Sphere with Euler integration


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
5 replies to this topic

#1 Irlan Robson   Crossbones+   -  Reputation: 3277

Like
0Likes
Like

Posted 09 February 2013 - 08:15 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 );

 

The code is right?

Seems like i'm having trouble with the numbers. They out of range... especially with the angular velocity!


Edited by irlanrobson, 11 February 2013 - 08:26 AM.

Fondly,

Irlan Robson


Sponsor:

#2 Irlan Robson   Crossbones+   -  Reputation: 3277

Like
0Likes
Like

Posted 10 February 2013 - 06:38 PM

someone have a similar code ??? 


Fondly,

Irlan Robson


#3 DT....   Members   -  Reputation: 487

Like
0Likes
Like

Posted 11 February 2013 - 11:14 AM

m_inertia_inverse = MakeMatrixFromQuaternion(orientation).transpose() * g_inertia * MakeMatrixFromQuaternion(orientation);

 

 

Would this work?

 

m_inertia_inverse = MakeMatrixFromQuaternion(orientation).transpose() * g_inertia.Inverse() * MakeMatrixFromQuaternion(orientation);



#4 Irlan Robson   Crossbones+   -  Reputation: 3277

Like
0Likes
Like

Posted 11 February 2013 - 11:49 AM

m_inertia_inverse = MakeMatrixFromQuaternion(orientation).transpose() * g_inertia * MakeMatrixFromQuaternion(orientation);

 

 

Would this work?

 

m_inertia_inverse = MakeMatrixFromQuaternion(orientation).transpose() * g_inertia.Inverse() * MakeMatrixFromQuaternion(orientation);

thanks but i've already done this in the constructor 


Fondly,

Irlan Robson


#5 DT....   Members   -  Reputation: 487

Like
0Likes
Like

Posted 12 February 2013 - 12:17 PM

  torque = position.cross(force);

 

 

 

What about:

 

r           =  some point on sphere  -  sphere position;

 

torque  =  r.cross( force );



#6 Irlan Robson   Crossbones+   -  Reputation: 3277

Like
0Likes
Like

Posted 13 February 2013 - 06:51 AM

  torque = position.cross(force);

 

 

 

What about:

 

r           =  some point on sphere  -  sphere position;

 

torque  =  r.cross( force );

thanks but the only force that actually i have, is the gravity force that is on the constructor ,,, 


Fondly,

Irlan Robson





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.



PARTNERS