enter image description here

Please see image first..

I have as input the following (I presume these are in effect Euclidean coordinates):

  • The angle and the length of the red line.
  • The angle and the length of the green line.
  • The angle of the purple line (but not the length!)

What I need to find out:

  • The intersection point between the blue and the purple lines. Or I can do with just the length of the purple segment between the start and the intersection point.

Any help much appreciated!!

  • $\begingroup$ Small clarification - if possible, I am looking for a solution that uses the angle-length coordinate system approach (i.e. not converting into conventional vector coordinates to do the calculation) as I need high performance on this calculation. Thank you. $\endgroup$ – Adelina Marinova Jul 14 '14 at 19:17

You know the angle between the red and green sides, call that $\beta.$ From the law of cosines, you know the length of the blue side, call that $b.$ Call the read and green sides $r,g.$ Call the opposite angles $\rho, \gamma. $ You know these from the law of sines.

The purple line splits the angle $\beta$ into two known pieces, call those $\beta_r$ on the red side, $\beta_g$ on the green side; also splits length $b$ into two pieces, $b_r,b_g.$ Call the purple length $p.$


$$ b_r + b_g = b, $$ $$ b_r^2 = r^2 + p^2 - 2 r p \cos \beta_r $$ $$ b_g^2 = g^2 + p^2 - 2 g p \cos \beta_g $$

  • $\begingroup$ you beat me by two minutes...upvote for fast typing ;-) $\endgroup$ – Thomas Jul 14 '14 at 19:47
  • $\begingroup$ thank you, this is exactly what I needed in this case $\endgroup$ – Adelina Marinova Jul 14 '14 at 21:25

the laws of sine and cosine for triangles would allow you to compute this. The law of sines says that in a triangle with side length $a, b, c$ and angles $\alpha, \beta, \gamma$ (where $\alpha$ is the angle opposite to $a$ and so on) you have the equality

$$\frac{\sin(\alpha)}{a} = \frac{\sin(\beta)}{b} = \frac{\sin(\gamma)}{c}$$

while the law of cosines says that

$$ a^2 + b^2 - 2 ab\cos\gamma = c^2 $$

which also applies if you 'rotate' $a, b c$ and the corresponding angles. You can apply it on the outer triangle to get the angle between the blue and green line (you know the angle between red and green and the length of the adjacent sides, the law of cosine gets you the lenght of the blue line), then again on the lower inner triangle to get the length of the purple line.

  • $\begingroup$ hi, not the nicest system. Don't see any pretty workaround. $\endgroup$ – Will Jagy Jul 14 '14 at 19:49

For a vector-based approach, let the two endpoints be given by position vectors $\mathbf{x}_1,\mathbf{x}_2$ and the intersection point by $\mathbf{x_3}=s\hat{n}$ where $\hat{n}$ is the direction of the purple line. The desired parameter is the length $s$.

To find this, we parameterize the blue line as $\mathbf{y}(t) = (1-t) \mathbf{x}_1+t \mathbf{x}_2$. Then the intersection equation is $$\mathbf{x}_3=s \hat{n} = (1-t) \mathbf{x}_1+t \mathbf{x}_2.$$ Were we in Cartesian coordinates, we could obtain two equations in the two unknowns $(s,t)$ by taking the components. In lieu of this, take dot products of the intersection equation with the three vectors to obtain $$s x_1 \cos\theta_{13} = (1-t) x_1^2 + t x_1 x_2 \cos\theta_{12}, \\ s x_2 \cos\theta_{23} = (1-t) x_1 x_2\cos\theta_{12} + t x_2^2,$$ where $\theta_{ij}$ is the angle between vectors $\{\mathbf{x}_i,\mathbf{x}_j\}$ and $x_i$ the corresponding length. Eliminating $t$ and solving gives

$$s=\frac{x_1 x_2 \sin^2\theta_{12}}{(x_2 - x_1 \cos\theta_{12})\cos\theta_{13} + (x_1-x_2\cos\theta_{12}) \cos\theta_{23}}$$ which is the desired representation of $s$ in terms of lengths and angles.

  • $\begingroup$ thank you, actually calculating this way might actually be tiny bit faster $\endgroup$ – Adelina Marinova Jul 14 '14 at 22:24
  • $\begingroup$ Glad to be useful. I wouldn't be surprised if it's equivalent to the law of sines/cosines approach, but I like the clarity of this approach a bit more. $\endgroup$ – Semiclassical Jul 14 '14 at 23:45

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.