Original Post
Hi, I am trying to do some angular kinetics but am having some problems. I am setting a value for angular velocity as 1.0f, there is no forces on the object so theretically it should continully spin around and around. Here is the step that i am using //global CTorque M; //moment acting on the mass CInertia I; //inertia acting on the mass CQuaternion qOrientation; //rotation of the object represented as a quaternion CVector3 angularVelocity; //velocity in rotation //local float mag; //step angularVelocity += I.inverseInertiaTensor * ( M.torque - math->Cross( angularVelocity,(I.inertiaTensor * angularVelocity))) * dt; // calculate the new rotation quaternion: qOrientation += ( qOrientation * angularVelocity ) * (0.5f * dt); // now normalize the orientation quaternion: mag = qOrientation.Magnitude(); if (mag != 0) qOrientation /= mag; If this was working right the angularVelocity should change but instead they are all over the place and quickly become infinity??? I dont know if this will help but i think the inertia tensor might be wrong... I use this method void CInertia::calculateInertiaTensor( int amountElements, CVector3 localInertia[], CVector3 pts[], CVector3* cg, float mass[] ) { int i = 0; float Ixx, Iyy, Izz, Ixy, Ixz, Iyz; Ixx = Iyy = Izz = Ixy = Ixz = Iyz = 0.0f; CVector3 *cgPosition; cgPosition = (CVector3*)malloc(amountElements*sizeof(CVector3)); //redefine each point as if the cg was the origin for( i = 0; i < amountElements; i++ ) { cgPosition.x = pts.x - cg->x; cgPosition.y = pts.y - cg->y; cgPosition.z = pts.z - cg->z; } //add up each elemnets inertia for( i = 0; i < amountElements; i++ ) { Ixx += localInertia.x + mass * ( cgPosition.y * cgPosition.y + cgPosition.z * cgPosition.z ); Iyy += localInertia.y + mass * ( cgPosition.z * cgPosition.z + cgPosition.x * cgPosition.x ); Izz += localInertia.z + mass * ( cgPosition.x * cgPosition.x + cgPosition.y * cgPosition.y ); Ixy += mass * ( cgPosition.x * cgPosition.y ); Ixz += mass * ( cgPosition.x * cgPosition.z ); Iyz += mass * ( cgPosition.y * cgPosition.z ); } //now define the inertiatensor and inverse inertia tensor inertiaTensor.setMatrix(Ixx, -Ixy, -Ixz, -Ixy, Iyy, -Iyz, -Ixz, -Iyz, Izz ); inverseInertiaTensor = inertiaTensor.Inverse(inertiaTensor); //free up the space free(cgPosition); } I am using this formula on a simple Cube (2.0f LxDxH and 100.0f mass) and it gives me (66.66f, 66.66f, 66.66f). I calulate the local inertia of the object using CVector3 momentInertia; momentInertia.x = ( mass * ( ( depth * depth ) + ( lenght * lenght ) ) ) / 12.0f; momentInertia.y = ( mass * ( ( height * height ) + ( lenght * lenght ) ) ) / 12.0f; momentInertia.z = ( mass * ( ( depth * depth ) + ( height * height ) ) ) / 12.0f; return momentInertia; then pass that along with all the points into the method above and it creates strange numbers all over 500.0f. So does any one see any thing wrong or can they point me in the right direction to online tutorial.