Advertisement
Guest User

Untitled

a guest
May 17th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1.  
  2. //angle setup
  3. float theta = chf('theta'); //-pi/2, pi/2
  4. float phi = chf('phi'); //-pi,pi
  5. float twopi = $PI * 2;
  6. float thetaStep = $PI/pts;
  7. float phiStep = twopi/pts;
  8.  
  9. //decalre point position and array to hold points
  10. vector pos;
  11. int globe[];
  12.  
  13. //superformula variables
  14. float a = 1;
  15. float b = a;
  16. float m1 = 4;
  17. float m2 = m1;
  18. float n1 = 12;
  19. float n2 = 15;
  20. float n3 = 15;
  21.  
  22.  
  23.  
  24.  
  25. float cosValue, sinValue, cosValue2, sinValue2;
  26.  
  27. for(int j=0; j<pts; j++){
  28.  
  29. for(int i=0; i<pts; i++){
  30.  
  31. //polar to cartesian coordinates
  32. cosValue = pow(abs(cos((m1*theta)*0.25)/a), n2);
  33. sinValue = pow(abs(sin((m2*theta)*0.25)/b), n3);
  34. r1 = pow((cosValue + sinValue), -(1/n1));
  35.  
  36.  
  37. cosValue2 = pow(abs(cos((m1*phi)*0.25)/a), n2);
  38. sinValue2 = pow(abs(sin((m2*phi)*0.25)/b), n3);
  39. r2 = pow((cosValue + sinValue), -(1/n1));
  40.  
  41. pos.x = (r1 * cos(theta)) * (r2 * cos(phi));
  42. pos.y = (r1 * sin(theta)) * (r2 * cos(phi));
  43. pos.z = r2 * sin(phi);
  44.  
  45.  
  46. globe[j] = addpoint(geoself(), pos);
  47. theta += thetaStep;
  48. phi += phiStep;
  49. }
  50.  
  51. theta += thetaStep;
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement