I am using the following code to rotate a point Pt about another point P1. It works fine, but is quite imprecise and the effect is quite visible when I use it to rotate a group of points. Since rotation is a one to one mapping, there should be very little distortion. Is there a better way to achieve the rotation?


private Sub RotatePoint(P1 as POINTAPI, Pt as POINTAPI, Angle as Single)
Dim rXConstTemp as Single, rYConstTemp as Single
Dim mX as Single, mY as Single
Dim SinAngle as Single, CosAngle as Single

SinAngle = Sin(Angle * 3.141592654 / 180)
CosAngle = Cos(Angle * 3.141592654 / 180)
rXConstTemp = P1.X * (1 - CosAngle) + P1.Y * SinAngle
rYConstTemp = P1.Y * (1 - CosAngle) - P1.X * SinAngle

mX = Pt.X * CosAngle - Pt.Y * SinAngle + rXConstTemp
mY = Pt.X * SinAngle + Pt.Y * CosAngle + rYConstTemp

Pt.X = mX
Pt.Y = mY
End Sub