# 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.

## 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 on other sites
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.

##### Share on other sites
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 on other sites
^ what he said. Also, you have to add the original components to the resulting transform.

##### Share on other sites
ty very mcuh. work like a charm

1. 1
Rutin
19
2. 2
JoeJ
15
3. 3
4. 4
5. 5

• 24
• 20
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631699
• Total Posts
3001776
×