RE: [Plib-users] 'World' to 'Local' body velocity transform
Brought to you by:
sjbaker
|
From: McEvoy, N. <nic...@ds...> - 2001-12-03 05:59:23
|
"Steve" wrote:
>So (in a nutshell) you want to transform the world-coordinate velocity into
>'body' coordinates.
Thanks for that (nice summary too) !!!
Yes, I have read 'Matrices can be your Friends' too. Good stuff ! :-)
So ... your_words-to-code seems to be something like this (just the velocity
conversion part from world-to-body) ...
{...
sgVec3 HPR, Velocity;
sgMat4 R1, VM;
// world velocity
sgSetVec3(Velocity, 0, 100, 0);
// testing heading changes
for (int i = 0; i >= -180; i-=45)
{
sgSetVec3(HPR, (float)i, 0, (float)i);
sgMakeRotMat4(R1, HPR);
sgInvertMat4(R1);
sgMakeTransMat4(VM, Velocity);
sgPreMultMat4(R1, VM);
// body velocity
sgCoord vel;
sgSetCoord(&vel, R1);
printf("HPR <%0.2f> <%0.2f> <%0.2f>\n", HPR[0], HPR[1],
HPR[2]);
printf("BodyVel <%0.2f> <%0.2f> <%0.2f>\n", vel.xyz[0],
vel.xyz[1], vel.xyz[2]);
}
...}
Thanks for your suggestion ... I will add it to my game tonight and see if
it fixes my problem ...
Nick
_________________________________________
Nick McEvoy
WorkMail: mailto:nic...@as...
HomeMail: mailto:ndm...@oz...
HomePage: http://members.ozemail.com.au/~ndmcevoy/
_________________________________________
|