The short short answer:
Yes, yes it is
The short, slightly more helpful answer:
read http://www.hardcorepawn.com/CoOrds/VectorMaths.pde and find the relevant chunks, and fix it to work properly (some functions return normalised results when they technically shouldn't)
The long, useful answer:
This is a simplified version of some code I wrote recently. The three rotate functions take a 3D point, rotate it, and return the rotated point. These do assume rotating around the origin though.
Code:
class Vector // for storing your verticies simply.
{
float x,y,z;
Vector(float _x, float _y, float _z)
{
x=_x;
y=_y;
z=_z;
}
}
Vector rotateX(Vector a,float ang)
{
float mz=a.z*cos(ang)+a.y*sin(ang);
float my=a.y*cos(ang)-a.z*sin(ang);
return new Vector(a.x,my,mz);
}
Vector rotateY(Vector a,float ang)
{
float mz=a.z*cos(ang)-a.x*sin(ang);
float mx=a.x*cos(ang)+a.z*sin(ang);
return new Vector(mx,a.y,mz);
}
Vector rotateZ(Vector a,float ang)
{
float mx=a.x*cos(ang)-a.y*sin(ang);
float my=a.y*cos(ang)+a.x*sin(ang);
return new Vector(mx,my,a.z);
}
So to use it you would do something like:
Code:
Vector[] corners;
... setup ...
corners=new Vector[8];
corners[0]=new Vector(-20,-20,-20);
corners[1]=new Vector(-20,-20,20);
corners[2]=new Vector(-20,20,-20);
corners[3]=new Vector(-20,20,20);
corners[4]=new Vector(20,-20,-20);
corners[5]=new Vector(20,-20,20);
corners[6]=new Vector(20,20,-20);
corners[7]=new Vector(20,20,20); //these points are written of the top of my head, one or two might be wrong...
...
... draw ...
for(int i=0;i<corners.length;i++)
{
corners[i]=rotateX(corners[i],0.1);
}
// Using these points to draw a cube is left as an exercise for the reader.
If you want to rotate a 3D point about an arbitary vector you'll have to look at http://www.hardcorepawn.com/CoOrds/VectorMaths.pde because it needs quite a few other functions I've defined to go with it.
It should be noted that that file is NOT of production quality.. there's a few idiosyncracies because it's evolved from my needs over a while, and some functions return a normalised result when they really shouldn't.