newsb

08-11-2011, 02:30 PM

Hi all,

I'm an openGL newbie. I don't understand the righthand rule here: "fElect1" is a variable that keeps increasing - minimal example (however not compilable) follows:

-----------

// Angle of revolution around the nucleus

static GLfloat fElect1 = 0.0f;

// Clear the window with current clearing color

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Reset the modelview matrix

glMatrixMode(GL_MODELVIEW);

glLoadIdentity(); // Replace current matrix with 4*4 identity matrix!

// Translate the whole scene out and into view

// This is the initial viewing transformation

glTranslatef(0.0f, 0.0f, -100.0f); // translates in direction (x,y,z)

// Red Nucleus - IN THE CENTER - NOT MOVING...

glColor3ub(255, 0, 0); // Sphere args: (radius, slices, stacks!)

// *** CREATE THS FIRST RED SPHERE (NON-MOVING): ***

glutSolidSphere(10.0f, 15, 15); // <============= SPHERE (IN CENTER)

glRotatef(fElect1, 0.0f, 0.0f, 1.0f); // around the vector x,y,z...

glTranslatef(40.0f, 0.0f, 0.0f);

// Sphere args: (radius, slices, stacks!)

glutSolidSphere(6.0f, 15, 15); // <============= SPHERE

glPopMatrix();

-----------

The last sphere goes CW around the center of the screen, as "fElect1" increases. Right is x, y is up, so z is outwards from the screen to the viewer, right?

I think the sphere should go CCW because positive rotation around the z-axis tells me that I put my right thumb pointing towards myself and then positive direction of rotation is in the fingertips direction, which is CCW. But the sphere goes the other way around.

I don't understand this - please advice. I hope I made myself clear and understandable.

I'm an openGL newbie. I don't understand the righthand rule here: "fElect1" is a variable that keeps increasing - minimal example (however not compilable) follows:

-----------

// Angle of revolution around the nucleus

static GLfloat fElect1 = 0.0f;

// Clear the window with current clearing color

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Reset the modelview matrix

glMatrixMode(GL_MODELVIEW);

glLoadIdentity(); // Replace current matrix with 4*4 identity matrix!

// Translate the whole scene out and into view

// This is the initial viewing transformation

glTranslatef(0.0f, 0.0f, -100.0f); // translates in direction (x,y,z)

// Red Nucleus - IN THE CENTER - NOT MOVING...

glColor3ub(255, 0, 0); // Sphere args: (radius, slices, stacks!)

// *** CREATE THS FIRST RED SPHERE (NON-MOVING): ***

glutSolidSphere(10.0f, 15, 15); // <============= SPHERE (IN CENTER)

glRotatef(fElect1, 0.0f, 0.0f, 1.0f); // around the vector x,y,z...

glTranslatef(40.0f, 0.0f, 0.0f);

// Sphere args: (radius, slices, stacks!)

glutSolidSphere(6.0f, 15, 15); // <============= SPHERE

glPopMatrix();

-----------

The last sphere goes CW around the center of the screen, as "fElect1" increases. Right is x, y is up, so z is outwards from the screen to the viewer, right?

I think the sphere should go CCW because positive rotation around the z-axis tells me that I put my right thumb pointing towards myself and then positive direction of rotation is in the fingertips direction, which is CCW. But the sphere goes the other way around.

I don't understand this - please advice. I hope I made myself clear and understandable.