OpenGL - Gire una 'curva' sobre el eje Y

Según mipregunt en Math Stackexchange:

Estoy trabajando en un proyecto para mi clase de Gráficos 3D. El proyecto está construido con C ++ y OpenGL / Glut. Básicamente, creo una ventana rectangular rectangular, subdividida en dos cuadrados. A la izquierda, tengo un plano de coordenadas bidimensional, que permite a los usuarios apuntar, hacer clic y definir una 'curva' de perfil. Luego necesito ajustar esta curva alrededor del eje Y n veces.

Entonces, ¿alguien podría guiarme sobre cómo usaría la trigonometría para calcular los valores X y Z de los puntos sucesivos? Si, por ejemplo, un usuario hace clic y crea el punto:

(1, 1, 0)

Y su resolución de barrido (n) se establece en, digamos, 10, luego necesito volver a dibujar ese punto cada 36 (360/10) grados alrededor del eje Y.

¿Estoy en lo cierto al suponer que la trigonometría me ayudará aquí? Si es así, ¿alguien puede aclararme un poco sobre cómo calcular la ubicación de un punto traducido en el espacio 3D? Ha pasado un tiempo desde que tomé Trig, y no creo que hayamos dejado espacio en 2D.

EDITA: Intenté usar:

x'=xcos(theta)-zsin(theta)

y'=y

z'=xsin(theta)+zcos(theta)

, según mi entendimiento de AMPerrine'sresponde, y no creo que haya funcionado como esperaba:

// this is in a loop

// setup the new angle
double angle = i>0 ? (360/sweepResolutionMod)*i : 0;

angle = angle * (M_PI/180);

// for each point...
for( int i=0; i<clickedPoints.size(); i++ )
{
    // initial point, normalized
    GLfloat tempX = (clickedPoints[i].x-250)/250;
    GLfloat tempY = (clickedPoints[i].y-250)/250;
    GLfloat tempZ = 0.0;

    // log the initial point
    cout << "(" << tempX << ", " << tempY << ", 0.0) by " << angle << " radians = ";

    // generate the new point
    GLfloat newX = (tempX * cos(angle)) - (tempZ * sin(angle));
    GLfloat newY = tempY;
    GLfloat newZ = (tempX * sin(angle)) - (tempZ * cos(angle));

    // log the new point
    cout << "(" << newX << ", " << newY << ", " << newZ << ")\n";

    // render the new point
    glVertex3d(newX, newY, newZ);
}

Esto no produce salida de pantalla, sino salida de consola de:

(0.048, -0.296, 0.0) by 0 radians = (0.048, -0.296, 0)
(0.376, -0.508, 0.0) by 0 radians = (0.376, -0.508, 0)
(0.72, -0.204, 0.0) by 0 radians = (0.72, -0.204, 0)
(0.652, 0.176, 0.0) by 0 radians = (0.652, 0.176, 0)
(0.368, 0.504, 0.0) by 0 radians = (0.368, 0.504, 0)

(0.048, -0.296, 0.0) by 0.628319 radians = (0.0388328, -0.296, 0.0282137)
(0.376, -0.508, 0.0) by 0.628319 radians = (0.30419, -0.508, 0.221007)
(0.72, -0.204, 0.0) by 0.628319 radians = (0.582492, -0.204, 0.423205)
(0.652, 0.176, 0.0) by 0.628319 radians = (0.527479, 0.176, 0.383236)
(0.368, 0.504, 0.0) by 0.628319 radians = (0.297718, 0.504, 0.216305)

(0.048, -0.296, 0.0) by 1.25664 radians = (0.0148328, -0.296, 0.0456507)
(0.376, -0.508, 0.0) by 1.25664 radians = (0.11619, -0.508, 0.357597)
(0.72, -0.204, 0.0) by 1.25664 radians = (0.222492, -0.204, 0.684761)
(0.652, 0.176, 0.0) by 1.25664 radians = (0.201479, 0.176, 0.620089)
(0.368, 0.504, 0.0) by 1.25664 radians = (0.113718, 0.504, 0.349989)

...

(0.048, -0.296, 0.0) by 6.28319 radians = (0.048, -0.296, -1.17566e-17)
(0.376, -0.508, 0.0) by 6.28319 radians = (0.376, -0.508, -9.20934e-17)
(0.72, -0.204, 0.0) by 6.28319 radians = (0.72, -0.204, -1.76349e-16)
(0.652, 0.176, 0.0) by 6.28319 radians = (0.652, 0.176, -1.59694e-16)
(0.368, 0.504, 0.0) by 6.28319 radians = (0.368, 0.504, -9.0134e-17)

No estoy seguro de qué es exactamente lo que está sucediendo aquí, pero me está costando mucho tratar de resolverlo, así que, por favor, no piensen que estoy tratando de obtener una doble reputación o algo así, estoy realmente atrapado .

EDITA 2: Aquí está toda mi rutina de visualización para mi subvista de perspectiva:

void displayPersp(void)
{
    glClear(GL_COLOR_BUFFER_BIT);

    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();  

    gluLookAt (-2.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0);

    // draw the axis
    glBegin(GL_LINES);
    // x
    glVertex3f(500.0, 0.0, 0.0);
    glVertex3f(-500.0, 0.0, 0.0);
    // y
    glVertex3f(0.0, -500.0, 0.0);
    glVertex3f(0.0, 500.0, 0.0);
    // z
    glVertex3f(0.0, 0.0, -500.0);
    glVertex3f(0.0, 0.0, 500.0);

    glEnd(); 

    cout << endl;

    // loop as many number of times as we are going to draw the points around the Y-Axis
    for( int i=0; i<=sweepResolutionMod; i++ )
    {
        cout << endl;

        // setup the new angle
        double angle = i>0 ? (360/sweepResolutionMod)*i : 0;

        angle = angle * (M_PI/180);

        // for each point...
        for( int i=0; i<clickedPoints.size(); i++ )
        {
            GLfloat tempX = (clickedPoints[i].x-250)/250;
            GLfloat tempY = (clickedPoints[i].y-250)/250;
            GLfloat tempZ = 0.0;

            cout << "(" << tempX << ", " << tempY << ", 0.0) by " << angle << " degrees = ";

            GLfloat newX = (tempX * cos(angle)) - (tempZ * sin(angle));
            GLfloat newY = tempY;
            GLfloat newZ = (tempX * sin(angle)) - (tempZ * cos(angle));

            cout << "(" << newX << ", " << newY << ", " << newZ << ")\n";

            glVertex3d(newX, newY, newZ);
        }

        // the following was my old solution, using OpenGL's rotate(), but that
        // didn't allow me to get back the new point's coordinates.

        /*
        glRotatef(angle, 0.0, 1.0, 0.0);

        // draw a line?
        if( clickedPoints.size() > 1 )
        {
            glBegin(GL_LINE_STRIP);

            for(int i=0; i<clickedPoints.size(); i++ )
            {     
                glVertex3f((clickedPoints[i].x-250)/250, (clickedPoints[i].y-250)/250, 0.0);     
            }

            glEnd();
        }

        // everyone gets points
        glBegin(GL_POINTS);

        for(int i=0; i<clickedPoints.size(); i++ )
        { 
            glVertex3f((clickedPoints[i].x-250)/250, (clickedPoints[i].y-250)/250, 0.0);     
        }

        glEnd();
        */
    }


    glutSwapBuffers();
}

EDIT 3: Aquí hay una ilustración terrible que ilustra lo que necesito hacer. Sé que la perspectiva parece estar apagada, pero lo que intento adquirir son las 'horizontales' verdes en la subvista derecha (esto está usando el código glRotatef () comentado arriba):

EDICIÓN FINAL (para futuras generaciones!):

quí está lo que finalmente puse a trabajar, después de discutir un poco de álgebra lineal con un maestro en la universidad:

void displayPersp(void)
{
   glClear(GL_COLOR_BUFFER_BIT);

   gluLookAt (-2.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0);

   glMatrixMode (GL_MODELVIEW);
   glLoadIdentity ();  

   // draw the axis
   glBegin(GL_LINES);
     // x
     glVertex3f(500.0, 0.0, 0.0);
     glVertex3f(-500.0, 0.0, 0.0);
     // y
     glVertex3f(0.0, -500.0, 0.0);
     glVertex3f(0.0, 500.0, 0.0);
     // z
     glVertex3f(0.0, 0.0, -500.0);
     glVertex3f(0.0, 0.0, 500.0);

   glEnd(); 

   cout << endl;

   double previousTheta = 0.0;

   for( int i=0; i<=sweepResolutionMod; i++ )
   {
     double theta = i>0 ? (360/sweepResolutionMod)*i : 0;

     theta = theta * (M_PI/180);

     if( clickedPoints.size() > 1 )
     {
       // the 'vertical' piece
       glBegin(GL_LINE_STRIP);

       for(int i=0; i<clickedPoints.size(); i++ )
       {     
         // normalize
         GLfloat tempX = (clickedPoints[i].x-250)/250;
         GLfloat tempY = (clickedPoints[i].y-250)/250;
         GLfloat tempZ = 0.0;

         // new points
         GLfloat newX = ( tempX * cos(theta) ) + ( tempZ * sin(theta) );
         GLfloat newY = tempY;
         GLfloat newZ = ( tempZ * cos(theta) ) - ( tempX * sin(theta) );

         glVertex3f(newX, newY, newZ);     
       }

       glEnd();

       // the 'horizontal' piece
       if( previousTheta != theta )
       {
         glBegin(GL_LINES);

         for(int i=0; i<clickedPoints.size(); i++ )
         {     
           // normalize
           GLfloat tempX = (clickedPoints[i].x-250)/250;
           GLfloat tempY = (clickedPoints[i].y-250)/250;
           GLfloat tempZ = 0.0;

           // new points
           GLfloat newX = ( tempX * cos(theta) ) + ( tempZ * sin(theta) );
           GLfloat newY = tempY;
           GLfloat newZ = ( tempZ * cos(theta) ) - ( tempX * sin(theta) );

           // previous points
           GLfloat previousX = ( tempX * cos(previousTheta) ) + ( tempZ * sin(previousTheta) );
           GLfloat previousY = tempY;
           GLfloat previousZ = ( tempZ * cos(previousTheta) ) - ( tempX * sin(previousTheta) );

           // horizontal component           
           glVertex3f(newX, newY, newZ);     
           glVertex3f(previousX, previousY, previousZ);     
         }

         glEnd();
       }
     }

     previousTheta = theta;
   }

   glutSwapBuffers();
}

Respuestas a la pregunta(3)

Su respuesta a la pregunta