0

I have two doubts. I have X and Y coordinates which I have listed below. I also have plotted coordinates as shown in picture below.

x = [0, 1, 1, 0, 0, 1]
y = [1, 1, 2, 2, 3, 3]

enter image description here

Now, I have decided to rotate the geometry in clockwise. Therefore, I have rotate all points at 45 degree (+ve) using below formula.

x_dash = x[i] * math.cos(theta) + y[i] * math.sin(theta)
y_dash = -x[i] * math.sin(theta) + y[i] * math.cos(theta)

After using above code (Formula), I got below results which shows new coordinate points after 45 degree clockwise rotation and after plotting, I got below plot.

x_dash = [0.8509035245341184, 1.3762255133518482, 2.2271290378859665, 1.7018070490682369, 2.552710573602355, 3.078032562420085]
y_dash = [0.5253219888177297, -0.3255815357163887, 0.19974045310134103, 1.0506439776354595, 1.575965966453189, 0.7250624419190707]

enter image description here

My questions:

(1) if I take two coordinates (X and Y) of one point and if I find an angle using theta = np.degrees(np.arctan2(y, x)), I did not get 45 degree. For example:

np.degrees(np.arctan2(0.5253219888177297, 0.8509035245341184))

Result: 31.68992191129556

However, when I found an angle of 1st point before rotation. np.degrees(np.arctan2(1, 0)), I got 90.0.

I would like to know the reason that why there is a differece between the angle of same point before and after the rotation.

(2) If I have a rotated geometry like in the 2nd picture and I do not know the angle of rotation. What should I do make that geometry without rotation (like in the first picture).

Kinldy help me with these questions.

Urvesh
  • 331
  • 4
  • 15
  • 1
    Second question is essentially a duplicate of https://stackoverflow.com/q/73533966/1468366 so please don't ask the same question twice and also please stick to one question per post. Mentioning related questions in the body of the question or in comments is fine, but answers to that should go there not here. – MvG Aug 30 '22 at 13:57
  • I will take care of it. Thank you for letting me aware about these rules! – Urvesh Aug 30 '22 at 13:58

1 Answers1

2

By default, math.sin() and math.cos() assumes that the arguments are in radians. So, the code considers the angle of rotation as 45 radians, and not 45 degrees.

You can define theta as: theta = numpy.radians(45)

Hope this clarifies everything.

Shreyas R
  • 31
  • 2
  • Please upvote if you found my answer helpful. Thank you. – Shreyas R Aug 30 '22 at 07:53
  • Thank you for your answer. I realized that, I made a mistake by considering the theta in radian instead of Degree. – Urvesh Aug 30 '22 at 09:08
  • I would like to ask you for your answer on my 2nd question that I wrote in my body. Would you please check it ans give your suggestions? – Urvesh Aug 30 '22 at 09:09