Paraboloid: Unterschied zwischen den Versionen

Aus DGL Wiki
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „<source lang="c"> void paraboloid(int slices,int subdivisions,int height) { int h,i; float alpha; float fh; float dh=(float)height/(float)subdivis…“)
 
K
 
Zeile 1: Zeile 1:
 
<source lang="c">
 
<source lang="c">
void paraboloid(int slices,int subdivisions,int height)
+
void paraboloid(int slices, int subdivisions, int height)
 
{
 
{
     int h,i;
+
     int   h, i;
 
     float alpha;
 
     float alpha;
 
     float fh;
 
     float fh;
     float dh=(float)height/(float)subdivisions;
+
     float dh = (float)height / (float)subdivisions;
     float dx=PI2/slices;
+
     float dx = PI2 / slices;
 
     glBegin(GL_TRIANGLE_STRIP);
 
     glBegin(GL_TRIANGLE_STRIP);
     for(h=0,fh=0.0f;h<subdivisions;h++,fh+=dh)
+
     for (h = 0, fh = 0.0f; h < subdivisions; h++ ,fh += dh)
 
     {
 
     {
         for(i=0,alpha=0.0f;i<=slices;i++,alpha+=dx)
+
         for( i = 0, alpha = 0.0f; i <= slices; i++, alpha += dx)
 
         {
 
         {
             glVertex3f(fh*cosf(alpha),fh*fh,fh*sinf(alpha));
+
             glVertex3f( fh * cosf(alpha),       fh * fh,             fh * sinf(alpha));
             glVertex3f((fh+dh)*cosf(alpha),(fh+dh)*(fh+dh),fh*sinf(alpha));
+
             glVertex3f((fh + dh) * cosf(alpha), (fh + dh) * (fh + dh), fh * sinf(alpha));
 
         }
 
         }
 
     }
 
     }

Aktuelle Version vom 18. Mai 2018, 19:39 Uhr

void paraboloid(int slices, int subdivisions, int height)
{
    int   h, i;
    float alpha;
    float fh;
    float dh = (float)height / (float)subdivisions;
    float dx = PI2 / slices;
    glBegin(GL_TRIANGLE_STRIP);
    for (h = 0, fh = 0.0f; h < subdivisions; h++ ,fh += dh)
    {
        for( i = 0, alpha = 0.0f; i <= slices; i++, alpha += dx)
        {
            glVertex3f( fh * cosf(alpha),        fh * fh,              fh * sinf(alpha));
            glVertex3f((fh + dh) * cosf(alpha), (fh + dh) * (fh + dh), fh * sinf(alpha));
        }
    }
    glEnd();
}