The functions below will take a vector argument, and the number of degrees to rotate that vector (could use the vector as the movement, or looking, whatever) they return the new vector after being rotated. 2 things to note, first the vector MUST be normalized. Second, you must know which way you want to rotate, IE, left or right around the axis you want to rotate around, or you could simply always rotate left, but instead of rotating 30 right, you simply rotate 330 left. Get it? Oh, by the way, the vector rotated will not have an up. Meaning, if you rotate the vector 0,0,-1 around the z axis, it wont change, thus if your using a viewing angle with this, you should probly also create an UP vector and rotate that as well, to determin which way is up.

Hope this is what you were looking for.

```
struct VectorStruct
{
float X, Y, Z;
}
VectorStruct RotateLeftXAxis(VectorStruct V1, float Degrees)
{
VectorStruct TempV1;
if(Degrees < 0)
{
Degrees = 360 + Degrees;
}
TempV1 = V1;
V1.Z = TempV1.Z * (cos(Degrees*PI/180)) + TempV1.Y * (sin(Degrees*PI/180));
V1.Y = TempV1.Y * (cos(Degrees*PI/180)) - TempV1.Z * (sin(Degrees*PI/180));
return V1;
}
VectorStruct RotateLeftYAxis(VectorStruct V1, float Degrees)
{
VectorStruct TempV1;
if(Degrees < 0)
{
Degrees = 360 + Degrees;
}
TempV1 = V1;
V1.X = TempV1.X * (cos(Degrees*PI/180)) + TempV1.Z * (sin(Degrees*PI/180));
V1.Z = TempV1.Z * (cos(Degrees*PI/180)) - TempV1.X * (sin(Degrees*PI/180));
return V1;
}
VectorStruct RotateLeftZAxis(VectorStruct V1, float Degrees)
{
VectorStruct TempV1;
if(Degrees < 0)
{
Degrees = 360 + Degrees;
}
TempV1 = V1;
V1.Y = TempV1.Y * (cos(Degrees*PI/180)) + TempV1.X * (sin(Degrees*PI/180));
V1.X = TempV1.X * (cos(Degrees*PI/180)) - TempV1.Y * (sin(Degrees*PI/180));
return V1;
}
VectorStruct RotateLeftAllAxis(VectorStruct V1, float Degrees[])
{
V1 = RotateLeftXAxis(V1, Degrees[x]);
V1 = RotateLeftYAxis(V1, Degrees[y]);
V1 = RotateLeftZAxis(V1, Degrees[z]);
return V1;
}
VectorStruct RotateRightXAxis(VectorStruct V1, float Degrees)
{
VectorStruct TempV1;
if(Degrees < 0)
{
Degrees = 360 + Degrees;
}
TempV1 = V1;
V1.Z = TempV1.Z * (cos(Degrees*PI/180)) - TempV1.Y * (sin(Degrees*PI/180));
V1.Y = TempV1.Y * (cos(Degrees*PI/180)) + TempV1.Z * (sin(Degrees*PI/180));
return V1;
}
VectorStruct RotateRightYAxis(VectorStruct V1, float Degrees)
{
VectorStruct TempV1;
if(Degrees < 0)
{
Degrees = 360 + Degrees;
}
TempV1 = V1;
V1.X = TempV1.X * (cos(Degrees*PI/180)) - TempV1.Z * (sin(Degrees*PI/180));
V1.Z = TempV1.Z * (cos(Degrees*PI/180)) + TempV1.X * (sin(Degrees*PI/180));
return V1;
}
VectorStruct RotateRightZAxis(VectorStruct V1, float Degrees)
{
VectorStruct TempV1;
if(Degrees < 0)
{
Degrees = 360 + Degrees;
}
TempV1 = V1;
V1.Y = TempV1.Y * (cos(Degrees*PI/180)) - TempV1.X * (sin(Degrees*PI/180));
V1.X = TempV1.X * (cos(Degrees*PI/180)) + TempV1.Y * (sin(Degrees*PI/180));
return V1;
}
VectorStruct RotateRightAllAxis(VectorStruct V1, float Degrees[])
{
V1 = RotateRightXAxis(V1, Degrees[x]);
V1 = RotateRightYAxis(V1, Degrees[y]);
V1 = RotateRightZAxis(V1, Degrees[z]);
return V1;
}
```

i’ve been beating around the bush about this topic for a while now and I wanted to know how to go about 3D space. [bare with me]

my problem is with complete 360 degree rotations about 3D space. I tried trig functions

sinandcosto rotate about a plane and that works fine but in 3D space it only works on the ‘positive’ quadrants. I triedvectormanipulations (cross product of a general UP vector with the forward vector to get the “left-right” orientation and then crossing the left-right vector with the forward to get the “up-down” vector…). now i’m back to trig functions in combination with spherical coords and i run to a similar problem [one of the ‘axis’ remains positive]. anybody got any hints?I also wanted to grease the wheels of just having a theoretical discussion about anything game-related: from cool effects, AI, whatever.

thanks