calculate diagonale

How to get x and y given only the diagonal line (of a golden section’s rectangle) ?
probably you’ll have a faster and more efficient answer than me

Hello.

The golden ratio is 1.618. I assume the short side is to the right and downwards from the diagonale.

If we insert 1.618xb for a in Pythagoras formulae, then we have that d^2 (diagonal)^2 = 3.617b^2
this gives that d = 1.90208412 (around 1.9)

so b = d/ 1.90208412

a is 1.618xb

you can control this by computing square root of ( a^2 + b^2)

(I have used b for y, and a for x). :slight_smile:

If I’ve understood the question:

(*
  (x ^ 2) + (y ^ 2) = (h ^ 2) (Pythagoras's Theorem)
  Golden ratio = 1.6180339887 (Wikipedia)
∴ x = y * 1.6180339887 (if landscape)
∴ ((y * 1.6180339887) ^ 2) + (y ^ 2) = (h ^ 2)
∴ (y ^ 2) * 2.618033988588 + (y ^ 2) = (h ^ 2)
∴ (y ^ 2) * 3.618033988588 = (h ^ 2)
∴ (y ^ 2) = (h ^ 2) / 3.618033988588
∴ y = ((h ^ 2) / 3.618033988588) ^ 0.5
*)

on sidesOfGoldenRectangle(h, orientation)
	set y to ((h ^ 2) / 3.618033988588) ^ 0.5
	set x to y * 1.6180339887
	
	if (orientation is "portrait") then set {x, y} to {y, x}
	
	return {x:x, y:y}
end sidesOfGoldenRectangle

sidesOfGoldenRectangle(1.902113032548, "landscape")

Hello.

Having seen Nigels handler, I had to check my solution from earlier, and provide a handler as well. :slight_smile: The two handlers provide the same solution, as far as I can see. Nigel’s constants for the gold ratio were more accurate, so used that one as well.

log phisides(10)
 --> 8.506508085898, 5.257311122823

on phisides(diagonal)
	if diagonal ≤ 0 then error "diagonal must be positive"
	set b to diagonal / 1.902113032
	set a to b * 1.6180339887
	return {a, b}
end phisides

Ah yes. The ((h ^ 2) / 3.618033988588) ^ 0.5 in my handler can be reduced to h / 1.902113032548, making our maths practically them same. Thanks!