timob256
timob256

Reputation: 158

can't get the archimedes spiral

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;
    }

enter image description here

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 ???

matematik model i give there

afler uncommented R

enter image description here

afler 5 sec :3

enter image description here

Upvotes: 0

Views: 160

Answers (1)

timob256
timob256

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

enter image description here

Upvotes: 1

Related Questions