Why is it that when I use glRotation I fail to get a rotation around a specified axis?
I include the following example code
//A structure that represents either a point
//or a vector in x,y,z
struct xyz { double p[3];}
//A structure that represents a set of 4
//vectors
struct xyzVB
{ xyz vect[4]; //vect[0]=Vector from parent
//vect[1]-vect[0] = unit x vector
//vect[2]-vect[0] = unit y vector
//vect[3]-vect[0] = unit z vector
};
xyzVB CoordSys1 = {0,0,0,
1,0,0,
0,1,0,
0,0,1};
const int SELECT_X_AXIS = 1;
const int SELECT_Y_AXIS = 2;
const int SELECT_Z_AXIS = 3;
//This is used to select the current axis
int AXIS = SELECT_Y_AXIS;
xyzVB CoordSys2 = {0,0,0,
(Arbitrary set of
Orthogonal unit vectors)};
xyz a = CoordSys1.vect[AXIS];
// A unit vector
xyz b = CoordSys2.vect[AXIS];
// A unit vector
//Note that DotProduct(a, b) is not zero
//‘c’ is the unit normal of ‘a x b’
//It serves as the axis of rotation
xyz c = CrossProduct(a,b);
//The angle between vectors ‘a’ and ‘b’ is
//the arc_cos (in degrees) of the dot
//product of ‘a’ & ‘b’
//I know it will only get CCW angles ranging
//from 0 to 180 degrees
//* note: DotProduct(a,b) != 0)
double ang = ArcCos_degrees(DotProduct(a,b));
glRotate(angle, c.p[0], c.p[1], c.p[2]);
//I use a screen 480,480 in size
glDrawWireSphere(22,8,8);
Using this code I can rotate about any axis other than the one specified by the variable AXIS. Why is this so?
email me a ax_deimos@yahoo.com