fabriciofreitag - 1 year ago 114

Ruby Question

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

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

```
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)

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**