MATLAB: Finding the angle of rotation given the slope of the line connecting two rotated points.

MATLABrotation angle in 2-space

I am trying to apply certain special affine transformations to sets in 2-space. One of the simplest problems I am working with: I have original points (3,8) and (6,1) that lie on a line with slope m = -7/3 . I would like to rotate these two points (counterclockwise through the origin) so that the rotated points lie on a new line with slope m = -1 .
This is easy if one can find the angle of rotation but I am having trouble even with mupad. I tried rotating the original two points with the 2×2 matrix
cos(w) -sin(w)
sin(w) cos(w)
and then solving for w in mupad but the output (right below) appears to show that the set of rotation angles are all complex valued which seems wrong.
(PI*k – (ln(21/29 + (20*I)/29)*I)/2, k, Z_)
If I can find a real value for w in either radians or degrees I think I can proceed. Am I right that this problem has an easy solution I am simply missing?

Best Answer

The rotation angle is easy to calculate,
w = atand(-1) - atand(-7/3) %clockwise rotation angle in degrees
It depends only on the slopes, not on where the center of rotation is.
Related Question