Rotating a 2d triangle around its center
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?
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:
where A is the angle in radians.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement