Jump to content
  • Advertisement
Sign in to follow this  
BornToCode

How Do i Get the X,Y Position After Rotation

This topic is 4869 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok the thing is that After i apply a set of Transformation and Concatenate them i was wondering how to get the new Position After the Object is Rotated. I try getting the _.41,._42,._43 of the Matrix but it keeps on giving me the same Thing which makes sense because all i am doing is Rotating but the problem is that with my bounding box i want to know what are the coordinates of the points that make the quad so i can reposition my bounding box around the mesh. This is For a 2D Game that i am making that uses Realtime Physics.

Share this post


Link to post
Share on other sites
Advertisement
If I have understood your problem correctly, you should be able to get your positions by adding cos(rotation) to your x coordinate and sin(rotation) to your y coordinate.

Share this post


Link to post
Share on other sites
Reading values straight out of the matrix does work in some cases, but for the most part it's just not going to work [smile]

D3DXVec2TransformCoord( ) is the function you'll be wanting. The raw maths behind matrix transforms isn't too difficult, so if you don't want to be using D3DX post back here and I'll see if I can dig out the actual formulae.

hth
Jack

Share this post


Link to post
Share on other sites
// Rotate point POS (X: float, Y:float) by fAngle degrees
void RotatePoint(POS* pPosition, double fAngle)
{
float iOldX = pPosition->X;
double fCos = cos(fAngle * 0.01745329251988);
double fSin = sin(fAngle * 0.01745329251988);
pPosition->X = (float)( (fCos * (double)pPosition->X) - (fSin * (double)pPosition->Y) );
pPosition->Y = (float)( (fSin * (double)iOldX ) + (fCos * (double)pPosition->Y) );
}

Share this post


Link to post
Share on other sites
Ok the function takes three parameters. i am checking the sdk but they don't say what the second parameter is about.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!