Finding the coordinates of a line, having another line and an angle between them

59 Views Asked by At

If I have a line, how do I find a second line that has the same extent as the first one, and crosses the first one in a given origin point and angle?

For example, in this image I need to find x2 and y2, which are the only variables I don't have.

1

There are 1 best solutions below

2
On BEST ANSWER

I'll give some hints.

  1. Translate the points so that $(x_0, y_0)$ is at the origin. (Subtract $x_0$ from the $x$ coordinates and $y_0$ from the $y$ coordinates.)
  2. Determine the angle that $(x_0, y_0)$ to $(x_1, y_1)$ makes with the positive $x$ axis.
  3. Subtract (or add, depending on the direction) $\theta$ from that angle, to get the angle that $(x_0, y_0)$ to $(x_2, y_2)$ makes with the positive $x$ axis. Call this angle $\phi$.
  4. Calculate the point that is a distance $d$ and angle $\phi$ from the origin. (Hint: use polar coordinates.)
  5. Translate all of the points back to where they were by undoing step 1.

Can you take it from here?

Spoiler:

Let $\alpha = \text{atan2} \frac{y_1-y_0}{x_1-x_0}$ where atan2 is the arctangent function that takes into account the signs of the arguments. Then $$x_2 = x_0 + d \cos(\alpha - \theta)$$ and $$y_2 = y_0 + d \sin(\alpha - \theta)$$