[Math] Find the width/height of a triangle given a side length and two lines

geometrytriangles

I'm a programmer and I came across a math problem in my current project that I can't figure out.

My situation looks like this.

enter image description here

Everything in black is known or I know how to figure out.

  • A and B are the two lines of which their equations are known.
  • h is the length of the side between the two lines
  • w is the width of the triangle
  • I is the point where the two lines intersect

And I want to figure out the value of w

It's worth mentioning that my triangle can be any kind of triangle, not just isosceles.

Best Answer

Let's call your two equations $f(x)=Ax+B$ (the upper one) and $g(x)=Cx+D$.

For exactly the right $x=x_h$ they are $h$ apart. We then have $$f(x_h)-h=g(x_h)$$ from which $x_h$ can be isolated.

At their intercept, with $x=x_I$ we have $f(x_I)=g(x_I)$, from which we can isolate $x_I$.

Then $$x_I-x_h=w$$

Related Question