could some one have a look at this. local roation to real world

Started by
3 comments, last by Eric_Brown 14 years, 1 month ago
// this is only for the Y rotation float matrix[16]; Item->Model->GetMatrix( matrix );// this is an engine that gets the matrix float matrixSinMinus = matrix[2]; float matrixSin = matrix[8]; float matrixCos = matrix[10]; // rotate local corners to there real world position float realWorldX,realWorldZ; struct p { float x,y;} point; realWorldX = (matrixCos * point.x) + (matrixSinMinus * point.z); realWorldZ = (matrixSin * point.x) + (matrixCos * point.z);
Advertisement
Okay. I've looked at it.
If there's something wrong with it, what's wrong?
If there's not, why post it?
Is there any particular reason why you're inlining parts of matrix multiplication instead of just multiplying your matrix with a vector?

To make it is hell. To fail is divine.

Quote:Original post by Zao
If there's something wrong with it, what's wrong?
If there's not, why post it?
Is there any particular reason why you're inlining parts of matrix multiplication instead of just multiplying your matrix with a vector?



i just want to make sure if this is right , its the first time that i have tryed to impliment it .

its done this way cause its 3d engine that get taught in first year off uni
It looks like what you are doing is taking a matrix assumed to be of the following form



Ripping out the sin and cos peices, and using them to rotate a vector in the x-z plane. This solution does work, but it only works if you are rotating around the y axis. If this is a special case where you are always going to rotate around the y axis, why not use a 2x2 matrix instead of a 4x4.

If you are looking for a more general solution, why not just do this?

This topic is closed to new replies.

Advertisement