We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have been mapping to write a code when I stumble upon this problem. Here in the code, line 11, I am mapping the i from 2-7 --> 0, 50 for R. Ideally this mapping shouldn't affect the value of i but it is affecting.
The problem -> when I map i from 0-7 it works and the letter "A" doesn't rotate but when I map i from 2-7 it affects the value of i and "C" is the letter which doesn't rotate, ideally it should be "A" no matter how do I map i for R
String[] s = {
"A", "B", "C", "D", "E", "F", "G"
};
void setup() {
size(300, 300);
}
int k=0;
void draw() {
background(-1);
for (int i=0; i<7; i++) {
float R = map(i, 2, 7, 0, 50);
float ang = i*360/7;
float x = width/2+R*cos(radians(ang)+radians(k));
float y = height/2+R*sin(radians(ang)+radians(k));
// println(i);
// if (i<4) {
fill(0);
text(s[i], x, y);
// } else {
// fill(0);
// ellipse(x, y, 5, 5);
// }
}
k++;
}
Answers
this is a bit unexpected, i guess, but perfectly valid. you can think of the arguments as defining a line that goes through 2, 0 and 7, 50 BUT one that is defined outside of the range x=2 to 7 - the line carries on from -infinity to +infinity.
@koogs thank for the reply :)
my concern wasn't the value of R but i. It is somehow getting affected by mapping function. For instance, if you run the code with line 11 as R = map(i,0,7,0,50); then the letter "A" remain in the center whereas when I change the line 11 to R = map(i,2,7,0,50); then the letter "C" remain in the center but ideally "A" should be in the center. What I am is not able to understand is that the when I am mapping the values for R why the value of i is changing ?
it isn't.
println is your friend.
R is changing. with 2, 7 you have a negative R for a and b and c has 0 radius. that's why c isn't moving and a and b are.
with 0, 7 a has an R of 0 which is why it stays still.
@koogs I am a real retard b-( I don't know what I was thinking before asking this stupid question. I am really sorry :(
And thank you soooo much for the help :) :) :)