I draw a rotated wxBitmap. Is there a function to calculate where on the rotated wxBitmap the mousePos is? Something to give the rotation parameters that transforms the position on screen to the position within the rotated bitmap?
I think I have seen something like this a while ago but cannot find it anymore.
PS: I know I can do this by hand, but it would be nice not to have to...
calculate screen pos > pos on rotated wxBitmap Topic is solved

 Super wx Problem Solver
 Posts: 361
 Joined: Tue Jun 20, 2006 6:47 pm
 Contact:
Re: calculate screen pos > pos on rotated wxBitmap
To rotate an image by angle α about a point P(x0,y0), you
p3 will point in the original image.
 translate by (x0,y0)
 perform the rotation
 translate back by (x0,y0)
 translate by (x0,y0) [this undoes step 3 above]
 perform the rotation by α [this undoes step 2 above]
 translate back by (x0,y0) [this undoes step 1 above]
Code: Select all
wxPoint p = ...;
wxPoint2DDouble p2(p);
wxAffineMatrix2D mat;
mat.Translate(x0, y0);
mat.Rotate(alpha*M_PI/180.0);
mat.Translate(x0, y0);
wxPoint2DDouble p3 = mat.TransformPoint(p2);
Re: calculate screen pos > pos on rotated wxBitmap
transformation matrix A transforms coordinates from Space to Space';p3 will point in the original image.
when inverted matrix A' transforms coordinates from Space' to Space;
so if you have matrix
Code: Select all
wxAffineMatrix2D mat;
Code: Select all
wxAffineMatrix2D matInversed = mat;
matInversed.Inverse();
ubuntu 16.04, wxWidgets 3.0.4