Sign in to follow this  
n3Xus

Rotating a 2d triangle around its center

Recommended Posts

n3Xus    951
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
Aardvajk    13205
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this