How to find third point coordinates given variables

132 views Asked by At

enter image description here

I need a small algorithm in ruby to find x and y.

1

There are 1 answers

1
Ben Behar On BEST ANSWER
slope = Math.tan(ang)
x = (dInf - dSup)/(2 * slope)
y = x*slope + (dSub/2)

Y will be either positive or negative depending on which corner you want.

The reasoning for this is that the equation for the top slanted line is: Y = Sin(ang) * X + (dSup/2)

So the question becomes "at what X do we get a Y = dInf/2"

Substituting Y: Sin(ang) * X + (dSup/2) = dInf/2

Rearranging: X = (dInf - dSup) / 2 Sin(ang)