Exercise 45

using rotation and sine cosine functions to draw patterns.


float k = 2/7.0;
int scaleIt = 400;

void setup() {
  size(800, 800);
  background(20);
  colorMode(HSB);
  strokeWeight(0.01);
  smooth();
}

void draw() {
  translate(width/2, height/2);
  //scale(width/2, height/2);
  float t = frameCount / 20.0;
  float x = cos(k*t) * sin(t) * scaleIt;
  float y = cos(k*t) * cos(t) * scaleIt; 
  stroke(255);
  line(0, 0, x, y);
}

The chart below shows the results of different parameters, from the wikipedia page on the rose formula.
Rose-rhodonea-curve-7x9-chart


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *