Haig Armen Educational Archive


Exercise 45

by Haig. Average Reading Time: less than a minute.

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

No comments on ‘Exercise 45’

Leave a Reply