Reputation: 333
I am trying to draw some ellipses like if they were in the perimeter of an imaginary circle.I have done my logic, I do not see where it fails. Basically what I do is move the starting point where I want, then get locations using trigonometry, given that the angle and the hypotenuse are kwown. See the code:
// Curve for 5 number
translate(width/6*3-30, width/6*4);
for(int alpha = 0; alpha < 120; alpha = alpha +5){
int radius = (int)random(30)+20;
int xpos = (int)cos(alpha)*350; int ypos= (int)sin(alpha)*350;
ellipse(xpos,ypos,radius,radius);}
}
Upvotes: 0
Views: 46
Reputation: 2854
cos()
and sin()
are expecting radians. Try sin(radians(alpha))
Also perhaps you should make xpos and ypos floats...
Upvotes: 1