Attribute Wrangle_Golden Ratio

   3905   2   0
User Avatar
Member
49 posts
Joined: Jan. 2016
Offline
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.

I will say that speaking generally, I do understand the golden ratio itself, how its derived, and the general need for a bit of trig (sin for x and cos for y) to get the desired result, but I just am not understanding why he designs his code the way he does.


Thank you!
Edited by jtk700cln - Aug. 25, 2017 23:21:35

Attachments:
wrangling_golden ratio_public.hipnc (73.6 KB)

User Avatar
Member
10 posts
Joined: May 2016
Offline
I don't know if this will help but imagine a pendulum with a paint bucket that drops paint at regular intervals. If we add more force the pendulum it will swing further on that line. Now if we pushed the pendulum at 90 degrees to its current swing, then it's not just going to stop its motion on its current line, but instead will start to move in a circular motion.

That is what is happening here. You have the X axis as cosine so it starts at 1 and goes to -1 the additional force we add on this axis is the golden ratio * the point number - since point numbers always increasing we get a consistently bigger value.

The other axis is sine so starts at 0 and goes through 1 to -1, that is our pushing force at 90 degrees to the other axis. The result of these two swings together is a spiral.
User Avatar
Member
472 posts
Joined: July 2005
Offline
Hi,

I think it will be easier, if you use a direct curve parameterisation. You can use ptnum and numpt from the input curve to get the relative point value which is between 0 and 1. This value can be used to map the point from the input curve on the curve you want (no matther where the input curve point exists in space). I've modified your example and added a wrangle with 2 examples (logarithmic spiral) and (ramp controled spiral).

Attachments:
wrangling_golden ratio_public_mod.hipnc (81.7 KB)

  • Quick Links