Game Development Reference
In-Depth Information
And finally, equation 9.5 tells us the total velocity of a point. If we remove the
linear component, we get the equation for the linear velocity of a point due only to
its rotation:
= θ
q rel
The rotation-induced velocity of a point (
q ) depends on its position relative to the
p ) and on the object's angular velocity ( θ ).
So we now have a set of equations that can get us from a unit of impulse, via the
impulsive torque it generates and the angular velocity that the torque causes, through
to the linear velocity that results.
Converting these three equations into code, we get
origin of the object ( q
Vector3 torquePerUnitImpulse =
relativeContactPosition % contactNormal;
Vector3 rotationPerUnitImpulse =
Vector3 velocityPerUnitImpulse =
rotationPerUnitImpulse % relativeContactPosition;
The result will be the velocity caused by rotation per unit impulse. As it stands, the
result is a vector: it is a velocity in world space. We are only interested in the velocity
along the contact normal.
We need to transform this vector into contact coordinates using the transpose
basis matrix we saw earlier. This would give us a vector of velocities that a unit impulse
would cause. We are only interested at this stage in the velocity in the direction of
the contact normal. In contact coordinates this is the X axis, so our value is the x
component of the resulting vector:
Vector3 velocityPerUnitImpulseContact =
real angularComponent = velocityPerUnitImpulseContact.x;
where the transformTranspose method is a convenience method that combines the
effect of transforming a vector by the transpose of a matrix. 3
3. It works by performing a regular matrix transformation, but it selects the components of the matrix by
row rather than column order. See the code on the CD for its implementation.
Search Nedrilad ::

Custom Search