Reputation: 113
Im working on a game and i have a problem. I hope someone helps me :
There are 3 specified points on the screen
P0 , P1, P2
P3 = Target point we need to find (X3 and Y3), if we have P1 and P2 positions.
What information we have :
1-P0 position (X,Y) is known.
2- Distance between P0 and P1 is known
3- Distance between P0 and P2 is known
4-The angle between Red line and Blue line is known
How can i find position of P1 and P2 (x1,y1 and x2,y2) ?
Second problem is more important :
2- If i have positions of P1 and P2 , How can i find P3 which is on the imaginary line passes through P1 and P2 and distance between P3 from P2 is an specific number? (40 in this example)
Upvotes: 1
Views: 369
Reputation: 71
You can't solve Part 1 of your Question. There is a known Point P0 and the Distance to an unknown Point P1. But to compute the Coordinates of P1 we need the angle of the Distance-line 1 (blue) with the x-Axis or with the y-Axis. There is only an angle with an other Distance line (Dist2, red) to an other unknown Point (P2).
So if you have the Distance between two Points and one Point is given, you need the information in which Direction the Distance line of these two Points shows. Therefore you need an angle with x or y-Axis.
This is transferable to 3-D Space. One Point is given and the Distance to another. But in 3-D we need two angles to describe the Direction to the unknown Point. In 2-D you have one right-angled Triangle to calculate the Coordinates of the unknown Point. In 3-D there are two right-angled Triangles, which is hard to draw or to imagine. But if you do it with Triangles instead of Vector Arithmetic (see Bens Answer to Part 2) you are able to solve similar Problems without learning Vector Arithmetic.
Maybe you can reduce Vector Arithmetic to Triangles.
Upvotes: 0
Reputation: 1637
You can solve the second problem with a little vector arithmetic.
The length of the vector P1->P2 is
d = sqrt((x2-x1)^2 + (y2-y1)^2)
The unit vector in the direction P1->P2 is therefore
((x2-x1)/d, (y2-y1)/d)
Multiply this by 40 to get P2->P3
(40*(x2-x1)/d, 40*(y2-y1)/d)
Finally, add P2->P3 to P2 to get P3
(x2 + 40*(x2-x1)/d, y2 + 40*(y2-y1)/d)
Upvotes: 1
Reputation: 2123
If you have P1 and P2 for part 2: The segment P1P2 makes an angle with the horizon given by theta = tan((P2.y-P1.y)/(P2.x-P1.x)), P3 is then at (40*cos(theta), 40*sin(theta)) RELATIVE to P2 (so consider it an offset from P2).
Upvotes: 0