Skip to main content
GameDev.net gamedev.net
🔒 Locked

Golden Ratio Rectangle!!!

Started by maverick20 Nov 1, 2006 at 12:17 PM 3 replies 2.2k views
Original Post
maverick20
maverick20
Hi there. Actually i want to write a program for the golden ration rectangle, does anyone has the code listing of it????ill be really gratefull...thnx...
Jenison
Jenison
for every 1 of x multiply y by 1.618

done

EDIT - or I should say

y/x = 1.618 so y = 1.618 * x and x = y/1.618
Nik02
Nik02
Also,
y = x * 0.5 * (1 + sqrt(5));
Niko Suni
maverick20
maverick20
Quote:
Original post by Jenison
for every 1 of x multiply y by 1.618

done

EDIT - or I should say

y/x = 1.618 so y = 1.618 * x and x = y/1.618


Can i get a code snippet of it....

lone_ranger
lone_ranger
an old VB function of mine

Private Sub nextr(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, n As Integer, m As Integer) If m > 0 Then  If (n = 0) Then    drawr x1, y1, x2, y2    nextr x1 + (x2 - x1) * iphi, y1, x2, y2, 1, m - 1  ElseIf (n = 1) Then    drawr x1, y1, x2, y2    nextr x1, y1 + (y2 - y1) * iphi, x2, y2, 2, m - 1  ElseIf (n = 2) Then    drawr x1, y1, x2, y2    nextr x1, y1, x2 - (x2 - x1) * iphi, y2, 3, m - 1  ElseIf (n = 3) Then    drawr x1, y1, x2, y2    nextr x1, y1, x2, y2 - (y2 - y1) * iphi, 0, m - 1  End If End IfEnd Sub


drawr draws a rectangle
iphi = 2/(1+sqrt(5))
m is the iterations


call the function with a initial golden rectangle and n = 0,1,2,3 for the orientation you want
Virtus junxit, mors non separabit

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.