Hi Everyone. I’m stuck with a homework assignment. I need to draw a geometric shape (I’ve chosen the rhodonea curve), show the use of an interative “for” loop and use a mouse command. (we have to show all the math).

I came up with code for the geometric rose shape. See first set of code below. Its probably not great code but works.

I then tried to recreate it using a ‘for’ loop in the second set of code below. It gets all messed up. I tried stepping through the debugger to see what I’m doing wrong, but the variable values are basically identical. Any suggestions on how to fix the code would be very appreciated. Thank you in advance.

CODE SET 1

```
//VARIABLES
float k = 2/9.0;
color persianBlue = color(44, 47, 222, 20);
int dcount = 0;// this a variable to track how many lines are drawn.
//SETUP
void setup()
{
size(800,800);
background(255);
strokeWeight (0.01);
}
void draw()
{
translate (width/2, height/2);
scale (200,200);
float t=frameCount/20.0;
float x=cos(k*t)*sin(t);
float y=cos(k*t)*cos(t);
stroke (persianBlue);
line (0,0,x,y);
dcount++;
if (dcount > 1067)
{
noLoop();
}
CODE SET 2
//VARIABLES
float k = 2/9.0;
color persianBlue = color(44, 47, 222, 20);
int dcount = 0;// this a variable to track how many lines are drawn.
//SETUP
void setup()
{
size(800,800);
background(255);
strokeWeight (0.01);
}
void draw()
{
translate (width/2, height/2);
scale (200,200);
for(float t = 0.05; t<54; t = t + 0.05)
{
//float t=frameCount/20.0;
float x=cos(k*t)*sin(t);
float y=cos(k*t)*cos(t);
stroke (persianBlue);
line (0,0,x,y);
}
}
}
```