Hopefully someone has done this before or has some magical insight.
I'm using an openGL matrix, which is a 16-element float array (1D, not 2D!!). The first four elements are the X axis orientation, the next 4 are the Y axis, the next 4 the Z axis, and the last 4 actual coordinates (the last number of each is always 0, except the very last which is one). As a 2D array (which we do multiply them in that manner too), it would look like this:
So a dead center point will beCode:X Y Z CC 0 4 8 12 1 5 7 13 2 6 9 14 3 7 10 15
henceCode:1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
The purpose of the matrix is to use it as the base for the location and orientation of a 3D object.Code:float GLmatrix[16]={1.0,0.0,0.0,0.0, 0.0,1.0,0.0,0.0, 0.0,0.0,1.0,0.0, 0.0,0.0,0.0,1.0};
The orientation of a single point seems irrelevent, but it can still be rotated, and you would rotate a cube (eg) the same way. So what I want is a simple function to spin this object around the y axis. I figured the way to do this would be to use the sin of the x-axis X value and the cos of the x-axis Z value:
Which works but it flattens the cube! So I get something that looks like those spinning "live bait" signs they have outside gas stations during the summer.Code:void YRotate (float deg, float matrix[16]) { float rads; if (deg==0.0) return; rads=deg/(2.0*GL_PI); /* math.h uses rads */ matrix[0]=sin(rads); matrix[2]=cos(rads); }
Any deep thoughts on what I missed?



LinkBack URL
About LinkBacks



