Jump to content

Recreating the Golden Ratio_ Attribute Wrangle


Recommended Posts

Hey all I am working my way through Ari Danesh's Attribute wrangle tutorial, and I am at the point where he uses a wrangle to generate a costumizable curve, one that uses the golden ratio value to dictate its curvature.  

I am having a little trouble understanding a specific point in the code (see attached file)  

Here is the full code

f@G = (0.618033989)+ch("pattern_offset"); //the golden ration in radians 

f@rad  = ch("radius"); 
@rad  *= ch("growth");    
f@rot  = @G * (@ptnum);   
@P.x  += @rad*cos(@rot)*@ptnum*.001;     
@P.z  += @rad * sin (@rot) * @ptnum *.001; 
@N.x  = @P.x;  
@N.z  = @P.z; 
@N.y  = @P.y * ((@Npt- @ptnum)*ch("flatness")*.1);  
@up   =  {0,1,0};


@pscale = (@ptnum/(@Npt - 1.0))*2;

 

 

My issue is with these three steps right here

f@rot  = @G * (@ptnum);   
@P.x  += @rad*cos(@rot)*@ptnum*.001;     
@P.z  += @rad * sin (@rot) * @ptnum *.001; 

 

 

I am failing to see how multiplying the ptnum by the golden ratio, then using the sin or cos of this value and assigning it to the points position in space, gives you the result you desire.  A bit of a technical breakdown of this would help.

 

Initially, I thought that I would have done it differently. I would have tried to use the golden angle (rather than golden ratio) and used it directly to direct the circular movement of my point values in my primary axis and secondary axis, and then controlled the y axis similar to the way he did with channels.   However, I realized this would only work if each point move happened sequentially in a solver or an l system.  If I applied the cos and sin of 137 to each point at the same time, I would just move the line entirely, not generate curvature.    

 

Ugh, I wish I understood this better.  Is this method something of a workaround in the first place?  Any help explaining Ari's method from a math perspective would be really helpful, along with perhaps alternative solutions to the same problem.  

 

Thank you!

 

 

 

 

 

 

 

 

wrangling_golden ratio_public.hipnc

Edited by JKeil
grammar
Link to comment
Share on other sites

ptnum is a useful per-point identifier increasing from zero. For example, in 100-point geo it is in range 0..99. It is being used in VOPs and wrangles like i variable being used inside for loops.

cos(angle) and sin(angle) together used to compute angle's position on circle of radius 1. Angle values need to be in range 0..2pi radians to make a full circle. Range 0..20pi will be enough to coil 10 times. To get different radius, multiply result by any value you want. If the value is not the same, but constantly increasing, like @ptnum * 0.001, you will get spiral.

Here is same thing rewritten a bit:

float angle = G * @ptnum;
float radius = @ptnum * 0.001;
x = cos(angle) * radius;
y = sin(angle) * radius;

 

Edited by f1480187
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...