Reputation: 158
I trying to draw spiral, but i get circle.
for(int i = 0 ; i < 121; i++)
{
for(int a = 0 ; a <= 3; a++)
{
if(a == 1){
vertires_chikl[d] = GLfloat(X + R * cos(t));
d++;
}
if(a == 2){
vertires_chikl[d] = GLfloat(Y + R * sin(t));
d++;
}
if(a == 3){
vertires_chikl[d] = GLfloat(0.0);
d++;
}
}
t = t+ 0.256f;
// we are moving in a circle
R = R + 0.00001f;
// circle shifted to the side (right and up)
// Y = Y+ 0.0001f;
// X = X+ 0.0001f;
}
why i do wrong ????
while I tried to change the function. As I remember when increasing the variable R there should be a growth and a change in the circumference. Doesn’t it happen why ???
afler uncommented R
afler 5 sec :3
Upvotes: 0
Views: 160
Reputation: 158
thank tkausl.
the mistake was that global variable static float R = 0.4f; // Radius of circle.
i make this local
float R = 0.4f; // Radius of circle.
for(int i = 0 ; i < 121; i++)
{
for(int a = 0 ; a <= 3; a++)
{
if(a == 1){
vertires_chikl[d] = GLfloat(X + R * cos(t));
d++;
}
if(a == 2){
vertires_chikl[d] = GLfloat(Y + R * sin(t));
d++;
}
if(a == 3){
vertires_chikl[d] = GLfloat(0.0);
d++;
}
}
t = t+ 0.256f;
// we are moving in a circle
R = R + 0.004f;
// circle shifted to the side (right and up)
// Y = Y+ 0.0001f;
// X = X+ 0.0001f;
}
result
Upvotes: 1