I have a euclidean vector a
sitting at the coordinates (0, 1)
.
I want to rotate a
by 90 degrees (clockwise) around the origin: (0, 0)
.
If I have a proper understanding of how this should work, the resultant (x, y) coordinates after the rotation should be (1, 0)
.
If I were to rotate it by 45 degrees (still clockwise) instead, I would have expected the resultant coordinates to be (0.707, 0.707)
.
theta = deg2rad(angle);
cs = cos(theta);
sn = sin(theta);
x = x * cs - y * sn;
y = x * sn + y * cs;
Using the above code, with an angle
value of 90.0 degrees, the resultant coordinates are: (-1, 1)
.
And I am so damn confused.
The examples seen in the following links represent the same formula shown above surely?
What have I done wrong?
Or have I misunderstood how a vector is to be rotated?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…