Game Development Reference
In-Depth Information
transformMatrix.data[1] = 2*orientation.i*orientation.j -
2*orientation.r*orientation.k;
transformMatrix.data[2] = 2*orientation.i*orientation.k +
2*orientation.r*orientation.j;
transformMatrix.data[3] = position.x;
transformMatrix.data[4] = 2*orientation.i*orientation.j +
2*orientation.r*orientation.k;
transformMatrix.data[5] = 1-2*orientation.i*orientation.i-
2*orientation.k*orientation.k;
transformMatrix.data[6] = 2*orientation.j*orientation.k -
2*orientation.r*orientation.i;
transformMatrix.data[7] = position.y;
transformMatrix.data[8] = 2*orientation.i*orientation.k -
2*orientation.r*orientation.j;
transformMatrix.data[9] = 2*orientation.j*orientation.k +
2*orientation.r*orientation.i;
transformMatrix.data[10] = 1-2*orientation.i*orientation.i-
2*orientation.j*orientation.j;
transformMatrix.data[11] = position.z;
}
void RigidBody::calculateDerivedData()
{
// Calculate the transform matrix for the body.
_calculateTransformMatrix(transformMatrix, position, orientation);
}
Later we will add calls to additional calculations to this method.
10.2
N EWTON 2 FOR R OTATION
In Newton's second law of motion, we saw that the change in velocity depends on a
force acting on the object and the object's mass:
¨
m 1 f
p
=
For rotation we have a very similar law. The change in angular velocity depends on
two things: we have torque τ rather than force, and the moment of inertia I rather
than mass:
θ
I 1 τ
=
Let's look at these two in more depth.
Search Nedrilad ::




Custom Search