I need to switch from the XY co-ordinate system shown above to the X'Y' co-ordinate system using System::Drawing::Drawing2D (i.e. GDI+). This is what I have in mind:
float rotation = // +90 below is because AB is the new vertical...
Math::Atan2(pB.Y - pA.Y, pB.X - pA.X) * 180.0 / Math::PI + 90.0f;
Matrix m;
m.Translate(pA.X, pA.Y);
m.Rotate(rotation);
m.Invert();
array<PointF> points = gcnew array<PointF>{ pC };
m.TransformPoints(points);
Is there a way to do this while minimizing rounding errors? Can I avoid the Atan2
(or other inverse trigonometric function) call here?