I am using the rotation of axis formula as follows:
Assuming θ is 30 degrees so in order to go back to un-rotated state I am simply using (360-30) for α (all in radians). However, I am not getting back to 0 degrees. I have added the code in python for verification, so everything seems fine (adding 90 degrees or π/2 for α) gives me correct offset however, adding offset to go back to "un-rotated" state is an issue.
What could be the problem?
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.patches import Ellipse
import numpy.random as rnd
angle=2 * np.pi * rnd.random(size=1)
print("angle",np.degrees(angle))
x_circle90 = np.cos(np.pi / 2)
y_circle90 = np.sin(np.pi / 2)
x_90 = (x_circle90 * (40 * 0.5))
y_90 = (y_circle90 * (50 * 0.5))
xx90 = x_90 * np.cos(angle) - y_90 * np.sin(angle) + 108
yy90 = x_90 * np.sin(angle) + y_90 * np.cos(angle) + 60
x_circle0 = np.cos(0)
y_circle0 = np.sin(0)
x_0 = (x_circle0 * (40 * 0.5))
y_0 = (y_circle0 * (50 * 0.5))
xx0 = x_0 * np.cos(angle) - y_0 * np.sin(angle) + 108
yy0 = x_0 * np.sin(angle) + y_0 * np.cos(angle) + 60
negation=(2*np.pi-angle)
x_circlen = np.cos(negation)
y_circlen = np.sin(negation)
x_n = (x_circlen * (40 * 0.5))
y_n = (y_circlen * (50 * 0.5))
xxn = x_n * np.cos(angle) - y_n * np.sin(angle) + 108
yyn = x_n * np.sin(angle) + y_n * np.cos(angle) + 60
fig = plt.figure()
ax = fig.add_subplot(111)
ax.add_patch(
Ellipse(xy=[108,60],
width=40,
height=50,
angle=np.degrees(angle),
fill=False, color='k', linewidth=1))
ax.plot(xx0, yy0, 'rp', color='blue', markersize=2)
ax.plot(xx90, yy90, 'rp', color='green', markersize=2)
ax.plot(xxn, yyn, 'rp', color='black', markersize=2)
ax.plot(108,60,'rp', color='red', markersize=2)
ax.set_xlim(xmin=0, xmax=200)
ax.set_ylim(0, 200)
ax.set_aspect('equal', adjustable='box')
plt.show()
plt.pause()
plt.close


