drawing 2 vectors ...

I have a problem (really ?!) : the foloowing code sould draw two vector with the same orientation… but it doesn’t work. I try to draw a vector in spherical coordonates ( the base is (1,angle[1],angle[0]) and sorry for the english …) with 2 rotations and with this cartesian composantes.
/-------------------------------------------------------------------------------------------
angle[2]={40,60};
anglerd[0]=angle[0]*PI/180;anglerd[1]=angle[1]*PI/180;
dir[0]=sin(anglerd[1])*cos(anglerd[0]);dir[1]=sin(anglerd[0])*sin(anglerd[1]);dir[2]=cos(anglerd[1]);

                      glColor3f(1,0,0);
                      glBegin(GL_LINES);
                      glVertex3f(0,0,0);glVertex3d(3*dir[0],3*dir[1],3* dir[2]); //vecteur directeur
                      glEnd();

                      //retrouver le vecteur directeur

                      glPushMatrix();
                      glRotated(angle[1]-90,0,1,0); 
                      glRotatef(angle[0],0,0,1); 
                      glColor3f(0,1,0);
                      glBegin(GL_LINES);
                      glVertex3f(0,0,0);glVertex3f(4,0,0);
                      glEnd();
                      glPopMatrix();

/------------------------------------------------------------------------------------------------
I hope my english is not so bad that it cannot be understand…

dir[0]=sin(anglerd[1])*cos(anglerd[0]);
dir[1]=sin(anglerd[0])*sin(anglerd[1]);
dir[2]=cos(anglerd[1]);

Shouldn’t it be something like this?:-

dir[0]=cos(anglerd[0])*sin(anglerd[1]);
dir[1]=sin(anglerd[0])*sin(anglerd[1]);
dir[2]=cos(anglerd[1]);

Am i possibly too blind to see the difference?

Yes, you must be blind. He changed the order of multiplication for dir[0]. Didn’t you see that?

i have tested the code for no results.
I sould explain the goal of this code :
I try to draw a ship that follows a terrain, so i succeed in calculate the altitude and the normal at (x,y) : the ship follows the terrain.
But now i want it also follows the angle of the terrain : so i use the normal, calculate its theta and phi coordonates (spherical base) and draw the ship :
(the ship follows the normal)
glPushMatrix();
glRotatef(theta,…);
glRotatef(phi,…);
glTranslatef(x,y,z);
DrawShip();
glPopMatrix();

It sould work ?

There are 3 tutorials that are basically about aligning an object along a vector that maybe helpful to you.
http://www.mfcogl.com/OpenGL%20Topics.htm

They also draw and rotate lots of vectors (coordinate axes.) The MFC is is used to setup the OpenGL window but the OpenGL code is valid for any system.

How did you know I was blind?
It’s cruel to mock the afflicted…

thanks a lot for your answers it works perfectly now )))))))))))))))))