fabriciofreitag - 6 months ago 31

Ruby Question

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

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)