Welcome to Fractal Forums

Fractal Software => Help & Support => Topic started by: arturv on March 21, 2012, 09:11:31 AM




Title: phyllotaxis parastichy
Post by: arturv on March 21, 2012, 09:11:31 AM
Hello! I'm new here. Also relatively new to programming and math.

I'm building sunflower pattern (phyllotaxis) in RSL (renderman) and I need to find secondary spirals (parastichy) and use them to define new x and y coordinates. I've got the pattern (phyllotaxis) in green and then parastichy arms (red and blue) matched by fudging some values in. You can see the values 0.0026 and 0.0010 used in defining parastichyR and parastichyL. But I'm curious how to find these values properly. How to define relationship between phyllotaxis pattern and parastichies or how to find spiral angles using existing variables (golden ratio etc)

(http://www.vill.ee/attachment.php?attachmentid=6901&d=1332316322)

Code:
  //cartesian to polar coordinate system
  float r = sqrt( pow( x, 2 ) + pow( y, 2 ));
  float theta = atan( x, y) / (PI * 2) + 0.5;

  float spread = .003; // spiral spreading factor
  float n = 150; // number of florets
  float floretR = .001; // floret size
  float phi = pow( (1 + sqrt(5))/2, 2 ); // golden ratio squared ( change + to - for mirrored spiral )
  float goldenA = 2*PI / phi; // golden angle 2.4 radians
  float goldenF = 1 / phi; // golden fraction 0.382

  float parastichyR = mod( (theta + ( 0.0026 / spread * r )) * 13, 1 ); // 13 spiral arms to right
  float parastichyL = mod( (theta - ( 0.0010 / spread * r )) * 21, 1 ); // 21 spiral arms to left

  float floret = 0; float i ,a , b; // init
  for(i=0; i<= n; i+=1)
  {
a =  mod( goldenF * i , 1 ); // rotate golden fractian on each count
b =  i * spread; // spreading radius. sqrt(i) for linear spread
if( pow( theta - a, 2) + pow( r - b, 2) <= floretR / sqrt(i))  // calculate a circle
    floret += 1; // draw a floret circle
  }     

 red = parastichyL;
 green = floret;
 blue = parastichyR;

I've stumbled across pretty cool website with java applets and all that does some explanation but just a bit beyond me.
http://www.math.smith.edu/phyllo

even some java source code for calculating parastitchies but it looks very different to my approach
http://www.math.smith.edu/~cgole/PHYLLOH/SUSAN/psyral.java

Any help appreciated

art.