We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I have a list of float numbers ranging from -1 to 1, and I want to map them on an arc and then connect them to the arc centre, as shown in the image below. The line of code for creating the arc is this one:
arc(width/2, weight/2, width-10, weight-10, PI-QUARTER_PI, TWO_PI + QUARTER_PI);
From what I've read, I should get the coordinates on the arc in this way: (x,y) = (rcosθ, rsinθ), but it doesn't seem to work correctly. I know that it's more of a maths question, but if someone could help me, it would be much appreciated!
Answers
I assume that -1 corresponds to the left end of the arc and +1 the right end of the arc if that is true then you can
where radius is the radius of the arc and cx, cy define the centre of the arc.
You basically want to map a range of values to the arc's circumference. That is simply done as follows:
theta = map(value, -1, 1, PI-QUARTER_PI, TWO_PI + QUARTER_PI);
(x,y) = (arc_x + rcos(theta), arc_y + rsin(theta))
And it works fine!
Thank you both for the fast reply. The answer from quark worked for me! :)
The answer from Alex_Pr was the same as mine except he hard coded the numbers for radius, cx and cy.