4

We have four points: a, b, c and d. We only know length of line cd and line ab. We also know that points c and d have same x coordinate, also points a and b have same x coordinate. Lines cd and ab are parallel. How can I find angle (marked as green) between lines ca and line db? Please provide example of calculations.

enter image description here

vasili111
  • 368
  • 3
    What have you tried? Also, if we only know the two orange segment lengths ($cd$ and $ab$), then the angle can be pretty much anything. We need to know something more. The length of the two black segments (that is, $ac$ and $bd$) would help, but even that is not entirely enough. – Arthur Jul 21 '14 at 07:40
  • The angle between the line segment $\text{CA}$ and $\text{DB}$ is clearly $?^{\circ}.$ – IAmNoOne Jul 21 '14 at 07:46
  • @Arthur Thank you for clarification. Will it be possible to calculate, if we will also know that points c and d have same y coordinate, also points a and b have same y coordinate? – vasili111 Jul 21 '14 at 07:50
  • No, same $y$ doesn't suffice, if $x$-es differ much the angle can be arbitrarily small. (BTW, you didn't say what the $Y$ direction is.) – CiaPan Jul 21 '14 at 08:19
  • I guess he meant "the same x-coordinate" - at least, according to the image and the usual conventions about x and y – Marco13 Jul 21 '14 at 08:20
  • @CiaPan Sorry. I mean same is x, noy y. Question corrected. – vasili111 Jul 21 '14 at 08:24
  • @Marco13 You are right. Thank you for correction. – vasili111 Jul 21 '14 at 08:25
  • The problem as it is right now still has infinitely many solutions. – Tunococ Jul 21 '14 at 08:48
  • @Tunococ Please provide any of solution with any example with actual calculations. – vasili111 Jul 21 '14 at 08:51
  • @vasili111 From your drawing, you can slide CD and AB in any direction while keeping the vertical orientation of both segments. The angle will vary as you slide them around. – Tunococ Jul 21 '14 at 08:55

4 Answers4

7

Given the points with their coordinates $a_x, a_y ... d_x, d_y$, you can compute the angle of each line to the x-axis (using the arcustangens function), and then just compute the difference between these angles.

So you can compute the angles

$\alpha_0 = atan2(c_y-a_y, c_x-a_x)$

and

$\alpha_1 = atan2(d_y-b_y, d_x-b_x)$

(see the wikipedia link for the definition of the $atan2$ function).

The angle between the lines is then simply $\alpha_1-\alpha_0$


EDIT: The example:

  • $a_x = 100$, $a_y = 5$
  • $b_x = 100$, $b_y = 0$
  • $c_x = 0$, $c_y = 8$
  • $d_x = 0$, $d_y = 0$

Now compute

$\alpha_0 = atan2(c_y-a_y, c_x-a_x) = atan2(3, -100)$ $\alpha_1 = atan2(d_y-b_y, d_x-b_x) = atan2(0, -100)$

According to the cases described in this image from wikipedia:

enter image description here

We have

$\alpha_0 = atan(3/-100) + \pi \approx 3.1116016487329152$

$\alpha_1 = atan(0/-100) + \pi \approx 3.141592653589793$

And the angle is then the difference

$\alpha = \alpha_1 - \alpha_0 \approx 0.02999100485687789 \approx 1.718°$

Marco13
  • 2,043
2

If you have two lines given by vector equations, say $\bf{p}+\lambda{\bf u}$ and ${\bf q}+\mu{\bf v}$, and the accute angle between the lines is $\theta$ then there is a well-known relationship:

$$\cos\theta = \left| \frac{{\bf u} \cdot {\bf v}}{\|{\bf u}\|\,\|{\bf v}\|} \right|$$

Notice that only the directions ${\bf u}$ and ${\bf v}$ of the two lines are needed.

If a line passes through points ${\bf a}$ and ${\bf c}$ then the line has direction ${\bf c}-{\bf a}$ because ${\bf c}-{\bf a}$ is the vector from ${\bf a}$ to ${\bf c}$. If you know all of the coordinates of the points then you can work out the direction vectors of the two lines and then apply the formula to get $\cos\theta$. Then use $\cos^{-1}$ to get $\theta$.

Fly by Night
  • 32,272
2

we make a line parellel to the line $bd$, showed in this picture:enter image description here

then the angle you want is equal to the angle $\angle cad'$, and $dd'=ab$, because $ab\parallel cd$. so $cd'=cd-ab$.

now we can calculate the angle $\angle cad'$ in the triangle $\bigtriangleup cad'$. $$\cos(\angle cad')=\frac{ac^2+bd^2-d'c^2}{2\cdot ac\cdot bd}$$ then you have the angle by the function $\arccos()$.

In fact your inital conditions are not enough. from the two following pictures, we know that:enter image description hereenter image description here

1) when we only know the length of $ab$ and $cd$, the angle between $ac$ and $bd$ depends the distance between $ab$ and $cd$;

2) though $ab$ and $cd$ has a certain distance $\Delta x$, the angle between $ac$ and $bd$ depends also the hight of $ab$.

Martial
  • 1,694
  • Can you please provide example of calculations? – vasili111 Jul 21 '14 at 08:44
  • $\tan \angle cad' = \frac {cd'}{ad'} = \frac {cd'}{bd}$, so $\angle cad' = \arctan \frac {cd'}{bd}$ – CiaPan Jul 21 '14 at 08:52
  • I think the calculation is very clear, and don't understand what kind of example you need. Perhaps you give all the initial numeric conditions, then I show you the calculations. – Martial Jul 21 '14 at 08:56
  • @CiaPan we are not sure that the triangle is a right triangle, so I don't think we can use the function $\tan$. – Martial Jul 21 '14 at 08:59
  • @Martial For example: length of ab=5, length of cd=8 . Can you please provide step by step calculations with that numeric conditions? – vasili111 Jul 21 '14 at 09:03
  • @Martial You're right, the image suggested a right angle but the description does not contain such condition. Sorry for that. Shall I delete my comment? Is there any way to mark it as wrong (but not remove to keep the comments chain consistent)? – CiaPan Jul 21 '14 at 09:09
  • @vasili111 I edit my answer, hope it helps you – Martial Jul 21 '14 at 09:32
  • @Martial Thank you for clarification. I understand now why my question is wrong. What if we add to my question that points d and b have both coordinate y=0 ? – vasili111 Jul 21 '14 at 09:51
  • @vasili111 I think you need also suppose that $x_d=0$, $x_b=x$, then this problem could be solved – Martial Jul 21 '14 at 10:28
0

If I understand you question correctly: cd and ab are parallel. So you can shrink your problem to a triangle. Where your requested angle (let's call him $\alpha$) depends on the angles of $cdb$ (here $\beta$) and $dca$ (here $\gamma$) or any other two angles in your figure.

Thus all these three angles must be $180° = \alpha + \beta + \gamma$ in the sum.

So I think your problem is under determined.

Matthias
  • 2,166