Reputation:
I have the following setting:
I know P1, P2 and the angle alpha, now how do i calculate the coordinates of P3? (Note: P3 is on the same circle with origin P1 and radius P1P2)
The blue lines indicate the coordinate system
Upvotes: 2
Views: 609
Reputation: 1449
Complex_To_Vector(Vector_To_Complex(P_2 - P_1) * ei*alpha) + P_1.
(Just for fun -- not a serious suggestion)
Upvotes: 2
Reputation: 137188
If you rotate the vector P1->P2 by alpha about P1 you'll get the vector P1->P3. Then knowing P1 you can get P3.
The basic equation for rotation about the origin is:
[ cos(α) -sin(α) ] [x]
[ sin(α) cos(α) ] [y]
You might have to change the signs with your coordinate system, but I always have to it by trial and error as I can never remember!
Don't forget - as S.C. Madsen says sin
and cos
expect angles to be in radians not degrees.
Wikipeida's article on rotation has more information.
Upvotes: 4
Reputation: 3886
The formula stated above from Wikipedia is usable here to rotate the vector P1->P2 (V12).
V12 = [0, -100]
When rotated (beware of α is -30 degrees in your drawing) the vector P1->P3 becomes
x' = V12(x)*cos(α) - V12(y)*sin(α) = 0*cos(-30) - (-100)*sin(-30) = -50
y' = V12(x)*sin(α) + V12(y)*cos(α) = 0*sin(-30) + (-100)*cos(-30) = -86.6
When translated with the point P1 the coordinates for P3 becomes
[x, y] = [-50+150, -86.6+210] = [100, 123.4]
Upvotes: 7
Reputation: 5256
The angle has to be in radians when invoking sin and cos, you state the angle alpha is 30, so it seems to be in degrees. Other than that I think 'gspr' and 'ChrisF' have given excellent advice on how to solve this.
Upvotes: 1
Reputation: 11227
Let r be the distance from P1 to P2. Then P3 lies r*sin(α) in the negative x-direction from P1, and r*cos(α) in the negative y-direction from P1. For more details, see Wikipedia on trigonometry. Hence P3 has coordinates P1 - (r*sin(α), r*cos(α)).
Sidenote: It's a shame SO doesn't have LaTeX support, like MO.
Upvotes: 1