Minggu, 18 Maret 2012

"butterfly" curve

x = cos(u) (ecos(u) - 2 cos(4 u) - sin(u / 12)5.0)


#include "stdlib.h"
#include "stdio.h"
#include "math.h"

#define N 10000

typedef struct {
   double x,y,z;
} XYZ;

int main(int argc,char **argv)
{
   int i;
   double u;
   XYZ p,plast;

   for (i=0;i<N;i++) {
      u = i * 24.0 * PI / N;
      p.x = cos(u) * (exp(cos(u)) - 2 * cos(4 * u) - pow(sin(u / 12),5.0));
      p.y = sin(u) * (exp(cos(u)) - 2 * cos(4 * u) - pow(sin(u / 12),5.0));
      p.z = fabs(p.y) / 2;
      colour = GetColour(u,0.0,24*PI,4);
      if (i > 0) {
         Do something with the line from plast to p
      }
      plast = p;
   }
}
 SOURCE: http://paulbourke.net/geometry/butterfly/

Tidak ada komentar:

Posting Komentar