Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help with Pythagoras

Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
01-04-2010 07:10
My brain has seized. Could someone help sort me out...

For a right-angled triangle, given a hypotenuse z and a ratio r, how do I calculate values of x and y such that x/y == r and (x*x) + (y*y) == (z*z)?

In other words, how do I change the aspect ratio of a prim face while keeping the length of the diagonal constant?
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
01-04-2010 07:19
1. x*x + y*y = z*z

2. x/y = r

x = r y

3. r*r*y*y +y*y = z*z

(r*r + 1) . y*y = z*z

y*y = z*z / (r*r + 1)

y = sqrt(z*z / (r*r + 1))

Plug that in the original to solve for x
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Ee Maculate
Owner of Fourmile Castle
Join date: 11 Jan 2007
Posts: 919
01-04-2010 07:25
If you want x/y = r but x^2 + y^2 = z^2 then let

x = z*sin(t)
y = z*cos(t)

where t is arctan(r).

Now for any ratio r and fixed z you can find x and y.
Pete Olihenge
Registered User
Join date: 9 Nov 2009
Posts: 315
01-04-2010 07:40
Many thanks guys, it works a treat. I guess I should've paid more attention during maths lessons :)