2
$\begingroup$

I need to get the second point in a line segment knowing its first point, distance and perpendicular line segment. The line segments need to intersect , thus the direction of the incomplete line segment could differ based on the location of its first point. The problem I have now is that I don't know how to obtain the direction of the incomplete line segment.

This is what is known:

a1 = (30, 30)

a2 = (10, 30)

b1 = (30, 35)

d = 30 (distance of line segment b)

enter image description here

I tried the following:

Get perpendicular slope a.

m = (b2.x - b1.x) / (b2.y - b1.y);

Get horizontal direction.

hd = ?  // either 1 or -1

Get a2.

a2.x = a1.x + d * cos(atan(m)) * hd;
a2.y = a1.y + d * sin(atan(m));

I am missing the step to get the horizontal direction of the slope of b, I was unable to recognize the pattern. Or perhaps there is a better and shorter algorithm to figure out point b2?

$\endgroup$
  • 2
    $\begingroup$ There are two possibilities for $B_2$. The drawing suggests that you’re to choose the one for which $\overrightarrow{B_1B_2}$ is rotated counterclockwise from $\overrightarrow{A_1A_2}$. Is that the case? $\endgroup$ – amd Nov 26 '16 at 6:41
  • $\begingroup$ @amd the drawing represents the wanted outcome. I will edit the question to make clear that the line segments need to intersect. $\endgroup$ – oddRaven Nov 26 '16 at 9:40
1
$\begingroup$

Hint

You could write

  • $$\vec{A_1A_2}•\vec{B_1B_2}=0$$

  • $$||\vec{B_1B_2}||^2=900$$

and solve the system.

$\endgroup$
1
$\begingroup$

Observe that $A_1A_2$ is a segment parallel to X-Axis. And also that $B_1$ is a point directly above $A_1$. So, the diagram looks like this :Image It's trivial to figure out the coordinates of $B_2$ now.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.