Rotating a 2d triangle around its center

Started by
3 comments, last by n3Xus 16 years, 5 months ago
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?
Advertisement
There are several different definitions for the center of a triangle: circumcenter, centroid, incenter, orthocenter, and so on. You'll need to decide what kind of center you want.
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.
^ what he said. Also, you have to add the original components to the resulting transform.
ty very mcuh. work like a charm

This topic is closed to new replies.

Advertisement