# Thread: Right angle triangle math

1. ## Right angle triangle math

Hi, I'm writing a physics engine in flash, i'm attempting to avoid trigonometry as much as possible to avoid rounding issues. I've reached a point where i basically need to draw right triangles where the ratio between the two shorter sides are constant and the hypotenuse can change. So in other words i need to be able to work out the lengths of 'a' and 'b' (in the basic a^2+b^2=c^2) if i know 'c' and a/b.

In my futile attemps i've come up with this a*a = c*c/(1+1/r*r) (r being a/b), now that will only work if a is equal to b which is a little useless.

if b = a/r then you could write it as a^2+(a/r)^2 = c^2, now what i need to do to get this to work is get 'r' over to the other side of the equation so we have just 'a' left on one side and 'c' and 'r' on the other. It has to be in this format because 'c' and 'r' are known and 'a' isn't.

Im not sure if this should be in the algebra forum or here but i was hoping someone might know a solution

thanks for you help !

2. Hello, Geo877!

Hi, I'm writing a physics engine in flash, i'm attempting to avoid trigonometry
as much as possible to avoid rounding issues. .
. . . But there will be rounding!
I've reached a point where i basically need to draw right triangles where the ratio
between the two shorter sides is a constant and the hypotenuse $\displaystyle c$ can change.

I need to be able to work out $\displaystyle a$ and $\displaystyle b$ if i know $\displaystyle c$ and $\displaystyle \frac{a}{b}$
Let the ratio be $\displaystyle r.$

So we have: .$\displaystyle \frac{a}{b} \:=\:r \quad\Rightarrow\quad a \:=\:br$

Substitute into $\displaystyle a^2+b^2\:=\:c^2$

. . $\displaystyle (br)^2 + b^2 \:=\:c^2 \quad\Rightarrow\quad b^2r^2+ b^2 \:=\:c^2 \quad\Rightarrow\quad b^2(r^2+1) \:=\:c^2 \quad\Rightarrow\quad b^2 \:=\:\frac{c^2}{r^2+1}$

Then: .$\displaystyle \boxed{b \;=\;\frac{c}{\sqrt{r^2+1}} }$

And: .$\displaystyle a \:=\:br \:=\:\frac{c}{\sqrt{r^2+1}}\cdot r \quad\Rightarrow\quad \boxed{a \:=\:\frac{cr}{\sqrt{r^2+1}}}$

3. ## thank you so much that was exactly what I was looking for

the title says it all