Jump to content
  • Advertisement
Sign in to follow this  
n3Xus

Rotating a 2d triangle around its center

This topic is 3890 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

hello, im trying to rotate a triangle around its center. so the triangle has point A, B and C. can someone point me to an equation for the point components so it will rotate?

Share this post


Link to post
Share on other sites
Advertisement
Assuming each point of the triangle is defined relative to its centre (e.g. (-10,0)(10,10)(-30,20) sort of thing), you can just do the following for each co-ordinate:


void Rotate(float &X,float &Y,float Angle)
{
float Tx=X,Ty=Y;

X=(Tx*cosf(Angle))-(Ty*sinf(Angle));
Y=(Ty*cosf(Angle))+(Tx*sinf(Angle));
}


where A is the angle in radians.

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!