Hi, I want to project or map points of specific locations to be within the confine of a circular space (not removing points). Considering map() function does mapping on 1 dimension, how can I do so to take into accounts the 2 dimensions?
Sample starter code below. For example if the mapping is horizontal, then the dots in the top part will be more crowded to fit in the circle. An alternative would be to project all the points onto polar coordinates which I can do. It would be technically easier but less generalizable: if need to map to an arbitrary shape instead such as polygon instead, then it won’t work.
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
for (let i=0; i<50;i++){
ellipse(random(400), random(400),20,20);
noLoop();
}
stroke(255);
noFill();
ellipse(200,200,400,400)
}
Thanks in advance for inputs.