1

I was doing image processing to determine the distance between two points in a picture. it involves a fair amount of geometry. One of the problems which I tried to solve using basic geometry but failed to arrive at a solution is the following. I have transformed the question into mathematical terms so that a wider audience could answer it.

fig

The sides a, b, c, and the angle alpha are given. The length x is to be found Using sine and cosine laws I`ve found: Using Cosine Law and, Using Sine Law

fig2

where beta is the angle opposite the side b

John Alexiou
  • 28,472
  • 11
  • 77
  • 133
  • Hi, can you give at least one example set of values in order to test the results? There isn't a simple formula here, and the answer will require some level of programming a numeric solution. – John Alexiou Jun 01 '20 at 13:41

1 Answers1

0

This is not a trivial problem, and maybe it should have been asked Math.SE.

But here is my take:

fig

Considering the triangle abx

b^2 = x^2 + a^2 - 2*a*x*cos(β)        #1

And the triangle a1cx

c^2 = x^2 + a1^2 -2*a1*x*cos(β)       #2
sin(α)/α1 = sin(β)/c                  #3

Three non-linear equations to be solved for x, a1 and β.

Subtract #2 from #1 to eliminate x^2 (with some simplifications)

b^2 - c^2  = -2*x *(a-a1)*cos(β)+a^2 -a1^2        #4

use #3 to eliminate β in terms of a1 in #4

b^2 - c^2 = -2*x*(a-a1)*sqrt(1 - c^2/a1^2*sin(α)^2)+a^2-a1^2  #5

Now subtract (a/a1)*#2 from #1 to eliminate a1^2

b^2 - a*c^2/a1 = -(a-a1)*(x^2-a*a1)/a1            #6

Equations #5 and #6 are two non-linear equations to be solved for x and a1.

From #5 we have x in terms of a1 with

x = a1*(a^2-a1^2-b^2+c^2)/(2*(a-a1)*sqrt(a1^2-c^2*sin(α)^2))    #7

Unfortunately using the above in #6 results in a sixth order polynomial to be solved for a1.

It can only be solved numerically at this point. If a1 is found, then #7 also gives us x.

0 = 4*a^2*c^2*g^2
+ a1*(4*a*g^2*(a^2-b^2-c^2))
+ a1^2*(a^4-2a^2(b^2+c^2+4g^2)+b^4+2b^2(2g^2-c^2)+c^4)
+ a1^3*(-4a(a^2-b^2-c^2-g^2))
+ a1^4*(2(3a^2-b^2-c^2))
+ a1^5*(-4*a)
+ a1^6

where g = c*sin(α)

John Alexiou
  • 28,472
  • 11
  • 77
  • 133
  • But then there will be 6 different solutions right? Geometrically, I see a unique solution. – Amit Krishna A Jun 02 '20 at 08:55
  • There will be a number of invalid solutions (complex numbers, or negative numbers) and fro the remaining one there will be multiple configurations possible. Like the `c` distance outside of the main triangle. Here is the part where if I had real numbers to work with I could further develop the algorithm based on valid solution branches. – John Alexiou Jun 02 '20 at 12:20