Reputation: 13923
I use C# WPF and im stuck with that for couple of days.
How do I find point M?
Upvotes: 0
Views: 65
Reputation: 25972
Basic trigonometry or application of a rotation matrix (not to forget: translate the center to the origin and after rotation back to its inital position):
XM=a+cos(C°)*(X1-a)-sin(C°)*(Y1-b)
YM=b+sin(C°)*(X1-a)+cos(C°)*(Y1-b)
The input to the trigonometric functions has to be in radians, 1°=pi/180, C°=C*1°.
In screen coordinates, you have to first replace all y components with their negatives to get a properly oriented cartesian coordinate system. And then back for screen coordinates. Combined, this leads to replacing Y1-b and YM-b with b-Y1 and b-YM, resulting in the formulas
XM=a+cos(C°)*(X1-a)-sin(C°)*(b-Y1)
YM=b-sin(C°)*(X1-a)-cos(C°)*(b-Y1)
which can be rearranged to
XM=a+cos(C°)*(X1-a)+sin(C°)*(Y1-b)
YM=b-sin(C°)*(X1-a)+cos(C°)*(Y1-b)
or
XM=a+cos(-C°)*(X1-a)-sin(-C°)*(Y1-b)
YM=b+sin(-C°)*(X1-a)+cos(-C°)*(Y1-b)
which is also geometrically sensible since a reflection on the x axis changes the direction of rotations.
Upvotes: 2