Hello! I’m trying to generate a sphere using circles of different sizes. I want it to be adapt if I change the NUM_RING variable. Right now, the my code creates overlapping circles, and I don’t get why. Maybe it’s somthing I don’t understand about the map function.

angleMode(RADIANS);
let i = map(this.layer, 0, this.NUM_RING, 0, TWO_PI);
let x = sin(i) * this.ballRadius;
let y = cos(i) * this.ballRadius;
this.ringRadius = y;
this.zPositionOffset = x;

Oh wow that works! thank you so much! I’m still having a hard time figuring out why the angle should not be from 0 to TWO_PI though Also, why did you devide the rad by two for the y variable?
Thanks so much

Yeah, when you look at the cos curve, for a full circle (aka TWO_PI) it goes up and down again (hence you had the double lines!). Using -PI/2 (or HALF_PI) to HALF_PI avoids this. In this segment of the cos graph it’s straight in one direction.