PDA

View Full Version : Problem multiplying rotation matrices together

Silvercord
02-26-2003, 10:50 AM
I am using this for a game, but I didn't put it in the game forum because more people view GD. Plus it's math oriented, therefore you don't have to be into game programming to possibly help me.

Anyway, from what I understand from OpenGL Game Programming you can multiply the Z axis rotation matrix by the Y axis rotation by the X axis rotation. It comes right out and says the final equations(the 'concatenation' of the three matrices), but I'm not exactly sure how they got there. I'm going to post the three matrices and then the final equations. Note the delta means the degrees travelled about that axis only. If I made any mistakes please point them out, it was a lot to copy. I tried making this as neat as possible, but the matrices keep being posted unaligned.

Z axis rotation matrix:

cosDelta -sinDelta 0 0
sinDelta cosDelta 0 0
0 0 1 0
0 0 0 1

Y axis rotation matrix;

cosDelta 0 sinDelta 0
0 1 0 0
-sinDelta 0 cosDelta 0
0 0 0 1

X axis rotation matrix:

1 0 0 0
0 cosDelta -sinDelta 0
0 sinDelta cosDelta 0
0 0 0 1

Here are the final equation describing how the X image, Y image and Z image are related to the concatenation of the 3 matrices above
X' = X[(cosZDelta) * (cosYDelta)] +
Y[cosZDelta) * (sinYDelta) * (sinXDelta) - (sinZDelta) *(cosXDelta] +
Z[(cosZDelta) *(sinYDelta) * (sinYDelta) - (sinZDelta) * (cosXDelta)]

Y' = X[(sinZDelta) * (cosYDelta)]+
Y[(sinZDelta) * (sinYDelta) * (sinXDelta) - (cosZDelta) * (cosXDelta)+
Z[(sinZDelta) *(sinYDelta) * (cosXDelta) - (cosZDelta) * (sinXDelta)]

Z' = -x*(sin?) + z*(cosYDelta)*(sinXDelta)]
I'm not sure if the question mark is a mistake from the book or not, unfortunately I suspect it is, but when I know what I'm doing I'll be able to figure out what it's supposed to be.

As I said I do not know how they multiplied the first three matrices together to get the final equations. I do know how to work with matrices, i.e the image matix will have the number of rows from the first matrix and the number of columns from the second matrix. I know how to multiply two matrices together (Matrix1Row[0][0] * Matrix2Column[0][0] add those together and continue until first column is filled). Anyay if anyone can shed some light onto what is going on I will be very happy.

rahaydenuk
02-26-2003, 12:47 PM
Originally posted by Silvercord
I am using this for a game, but I didn't put it in the game forum because more people view GD. Plus it's math oriented, therefore you don't have to be into game programming to possibly help me.

Anyway, from what I understand from OpenGL Game Programming you can multiply the Z axis rotation matrix by the Y axis rotation by the X axis rotation. It comes right out and says the final equations(the 'concatenation' of the three matrices), but I'm not exactly sure how they got there. I'm going to post the three matrices and then the final equations. Note the delta means the degrees travelled about that axis only. If I made any mistakes please point them out, it was a lot to copy. I tried making this as neat as possible, but the matrices keep being posted unaligned.

Z axis rotation matrix:

cosDelta -sinDelta 0 0
sinDelta cosDelta 0 0
0 0 1 0
0 0 0 1

Y axis rotation matrix;

cosDelta 0 sinDelta 0
0 1 0 0
-sinDelta 0 cosDelta 0
0 0 0 1

X axis rotation matrix:

1 0 0 0
0 cosDelta -sinDelta 0
0 sinDelta cosDelta 0
0 0 0 1

Here are the final equation describing how the X image, Y image and Z image are related to the concatenation of the 3 matrices above
X' = X[(cosZDelta) * (cosYDelta)] +
Y[cosZDelta) * (sinYDelta) * (sinXDelta) - (sinZDelta) *(cosXDelta] +
Z[(cosZDelta) *(sinYDelta) * (sinYDelta) - (sinZDelta) * (cosXDelta)]

Y' = X[(sinZDelta) * (cosYDelta)]+
Y[(sinZDelta) * (sinYDelta) * (sinXDelta) - (cosZDelta) * (cosXDelta)+
Z[(sinZDelta) *(sinYDelta) * (cosXDelta) - (cosZDelta) * (sinXDelta)]

Z' = -x*(sin?) + z*(cosYDelta)*(sinXDelta)]
I'm not sure if the question mark is a mistake from the book or not, unfortunately I suspect it is, but when I know what I'm doing I'll be able to figure out what it's supposed to be.

As I said I do not know how they multiplied the first three matrices together to get the final equations. I do know how to work with matrices, i.e the image matix will have the number of rows from the first matrix and the number of columns from the second matrix. I know how to multiply two matrices together (Matrix1Row[0][0] * Matrix2Column[0][0] add those together and continue until first column is filled). Anyay if anyone can shed some light onto what is going on I will be very happy.

Hi,

Remember that although matrix multiplication is not commutative, it is associative, so it doesn't matter which two matrices you multiply together first in the above example, as long as the overall order is kept.

So, you want to create a composite matrix, which has the effect of a rotation about Z, then a rotation about Y, then a rotation about X. Remember that the non-commutativity of matrix multiplication still stands with rotations; the fact that the result of combining rotations depends on the order in which you perform them is a geometric fact about rotations. It is easy to see that the non-commutativity of rotations is a geometric fact. Just hold a non-cubical rectangular box in your hands and try rotating it by 90 degrees successively about two different axes, note the resulting orientation, then return it to its original orientation and perform the same two rotations but in the opposite order. Therefore, we must multiply the three matrices (we will call them Z, Y and X respectively) in the order ZYX. But due to matrix associativity, it doesn't matter whether we evaluate ZY first or YX first. If you evaluate ZY first (call it P), then simply multiply that by X, (in the order PX) to get the final composite matrix. If you evaluate YX first (call it G), then simply multiply that by Z, (in the order ZG) to get the final composite matrix.

By the way, your definitions for each individual rotation matrix are correct, and I'm sure you can now mulitply them together as explained to check the last bit.

P.S. You've used 'delta' for your angle variable in all of the above rotations, I don't know whether or not you intended to do this, as it would obviously only allow a rotation of the same amount around each axis.

I hope this helps,

Regards,

Silvercord
02-26-2003, 04:40 PM
That clears things up quite a bit, thank you very much!!! When I get this temporary matrix P do I still follow standard matrix multiplication (rows of P multiplied by columns of X or Z). Is it incorrect for ZX to be P and then multiply by Y?(it seems that it is incorrect to do that). These equations are eventually going to be used for changing the view vectors of the camera in a program I'm working on, therefore do I even need the rotation about the Z axis matrix?

I meant for the deltas to be completely different variables :)

rahaydenuk
02-26-2003, 05:41 PM
Originally posted by Silvercord
That clears things up quite a bit, thank you very much!!! When I get this temporary matrix P do I still follow standard matrix multiplication (rows of P multiplied by columns of X or Z).

If we are defining P = ZY to start as previously, then to get the composite matrix ZYX, you will need to multiply P by X on the right, i.e. PX as this is then equal to (ZY)X = ZYX.

If we are instead defining another matrix G = YX to start, then we need to multiply by Z on the left, i.e. ZG as this is then equal to Z(YX) = ZYX.

Remember that due to the non-commutativity of matrix multiplication, you need to take into account whether you are multiplying one matrix by another on the left or the right. They will (in general) produce different results.

All of these individual matrix multiplication operations are no different to what they were when you were just multiplying two matrices together. For example, to evaluate ZYX, take P = ZY and evaluate ZY just as standard matrix multiplication (i.e. rows of Z by columns of Y), then multiply the resultant matrix P by X to get PX in the standard fashion (i.e. rows of P by columns of X).

Originally posted by Silvercord
Is it incorrect for ZX to be P and then multiply by Y?(it seems that it is incorrect to do that).

We are trying to find ZYX, and if we were to define P = ZX, multiplying either side of P (ZX) by Y would produce either YZX or ZXY, which is not equal (in general) to ZYX for matrices, due to the non-commutativity of matrix multiplication. So, yes this would be incorrect; you should start either by evaluating YX or ZY and then multiplying by the other matrix (the one left out) on the correct side.

Originally posted by Silvercord
These equations are eventually going to be used for changing the view vectors of the camera in a program I'm working on, therefore do I even need the rotation about the Z axis matrix?

I'm not a game/graphics-programming expert, but I've done a bit of DirectX. If we assume that in camera space, the camera, or viewer, is at the origin, looking in the z-direction, as in DirectX, I can't immediately see a reason for wanting to have a rotation about the Z-axis in the view matrix transformation. I can see a rotation about the X-axis acting as adjustment of pitch (i.e. looking up and down), and then a rotation about the Y-axis as the adjustment for the camera rotating around, as if the user has turned his head, but unless you get complicated, then I see no *common* use for including a Z-axis rotation component in the view matrix transformation (obviously, you would probably need it for flight simulators etc.).

Having said this, you should remember however that the view matrix, V is generally defined as a combination of a translation matrix, T and then the three rotational component matrices, X, Y and Z about their three respective co-ordinate axis, (V = T*X*Y*Z), so officially, it does include a rotational component about the Z-axis. I wouldn't worry, though if you find yourself not needing it.

Originally posted by Silvercord
I meant for the deltas to be completely different variables :)

That's what I thought. :)

Hope this helps,

Regards,

Silvercord
02-27-2003, 12:11 PM
hi there, sorry I didn't get a chance to respond last night. All of your answers and explanations were very concise therefore I do not currently have anymore questions (that's a good thing). I'm doing this for a game, so I should have this working within a few days. I can post it when I get it working if you want me to. I think I might try using this matrix (the concatenation of the Z Y and X rotation matrices) as well as the rotation about an arbitrary axis matrix.

All right, take care, talk to you later.

rahaydenuk
02-27-2003, 12:32 PM
Originally posted by Silvercord
hi there, sorry I didn't get a chance to respond last night. All of your answers and explanations were very concise therefore I do not currently have anymore questions (that's a good thing). I'm doing this for a game, so I should have this working within a few days. I can post it when I get it working if you want me to. I think I might try using this matrix (the concatenation of the Z Y and X rotation matrices) as well as the rotation about an arbitrary axis matrix.

All right, take care, talk to you later.

OK, glad I could help! :D

I'd be interested in seeing your game, when you've got it working and I'm sure others would be too; I'll look forward to taking a look.

Have fun!

Regards,

Silvercord
02-27-2003, 10:05 PM
I have thought of more questions. I am trying to figure out how these matrices are derived but I honestly don't get it 100%. I am using the Y axis rotation matrix for this example. I am drawing pictures of a triangle with the hypotenuse as the view vector. I am then trying to figure out why the new vector's X component is equal to the cos(theta) multiplied by the original x plus the sin(theta) multiplied by the original z component (X' = cos(theta) * X + sin(theta) * z). Likewise I do not know how the calculation for the new Z component is derived (-sin(theta) * x + cos(theta) * z). If you could explain this using properties of triangles and vectors I will probably have a much better understanding of what is going on here. I want to get a very fundamental understanding of this.

rahaydenuk
02-28-2003, 05:11 AM
Originally posted by Silvercord
I have thought of more questions. I am trying to figure out how these matrices are derived but I honestly don't get it 100%. I am using the Y axis rotation matrix for this example. I am drawing pictures of a triangle with the hypotenuse as the view vector. I am then trying to figure out why the new vector's X component is equal to the cos(theta) multiplied by the original x plus the sin(theta) multiplied by the original z component (X' = cos(theta) * X + sin(theta) * z). Likewise I do not know how the calculation for the new Z component is derived (-sin(theta) * x + cos(theta) * z). If you could explain this using properties of triangles and vectors I will probably have a much better understanding of what is going on here. I want to get a very fundamental understanding of this.

Deriving the rotation matrices is quite a complicated topic. There are quite a few ways to go about it, including by differential equations or by looking at vector components. The following website gives a couple of different derivations of Rodriques' Formula, which is used to find rotation matrices:

http://www.cs.berkeley.edu/~ug/slide/pipeline/assignments/as5/rotation.html

I hope this helps,

Regards,

Silvercord
02-28-2003, 07:01 AM
I decided to skip out using the z axis rotation, because it does not seem like it will be used in my game (how can you even have a Z component in camera movement when you are checking for mousemovement in 2d screen coords?). I haven't multiplied matrices together in quite a while, but when I multiplied the Y axis rotation matrix by the X axis rotation matrix I got this matrix. I am pretty sure it is correct but I would be happy if you could check it for errors (better safe than sorry before putting it into code)

concatenation between Y and X axis rotation matrices:

cosYDelta sinYDelta + sinXDelta sinYDelta * cosXDelta
0 cosXDelta -sinXDelta
-sinYDelta cosYDelta * sinXDelta cosYDelta * cosXDelta

the final equations (what it will look like in code because I am not using a matrix class)

X' = X * cosYDelta +
Y * sinYDelta * sinXDelta +
Z * sinYDelta * cosXDelta

Y' = Y * cosXDelta +
Z * -sinXDelta

Z' = X * -sinYDelta +
Y * cosYDelta * sinXDelta +
Z * cosYDelta * cosXDelta

rahaydenuk
02-28-2003, 07:53 AM
Originally posted by Silvercord
I decided to skip out using the z axis rotation, because it does not seem like it will be used in my game (how can you even have a Z component in camera movement when you are checking for mousemovement in 2d screen coords?).

Well you're right, you can only have rotation about two axis, as the mouse only has two axis of movement. Flight simulators etc., which would require rotation about the z-axis (for barrel-rolls etc.) would usually have the user press a mouse button to switch one of the mouse's co-ordinate axis to representing the z-axis rotation, or it would be done by keyboard.

Originally posted by Silvercord
I haven't multiplied matrices together in quite a while, but when I multiplied the Y axis rotation matrix by the X axis rotation matrix I got this matrix. I am pretty sure it is correct but I would be happy if you could check it for errors (better safe than sorry before putting it into code)

concatenation between Y and X axis rotation matrices:

cosYDelta sinYDelta + sinXDelta sinYDelta * cosXDelta
0 cosXDelta -sinXDelta
-sinYDelta cosYDelta * sinXDelta cosYDelta * cosXDelta

the final equations (what it will look like in code because I am not using a matrix class)

X' = X * cosYDelta +
Y * sinYDelta * sinXDelta +
Z * sinYDelta * cosXDelta

Y' = Y * cosXDelta +
Z * -sinXDelta

Z' = X * -sinYDelta +
Y * cosYDelta * sinXDelta +
Z * cosYDelta * cosXDelta

One little thing, I find it very confusing to read your matrix, maybe you could attach an image next time?

From what I can see, it looks like you've made one typo, but apart from that it's fine. I've attached the correct product matrix for the y-axis rotation matrix multiplied by the x-axis rotation matrix (in that order) as an image for readability, so you can see where you made the mistake (you've used a '+' instead of a '*' for one element of the product matrix).

In order to get the equations for x', y' and z', we need to use the product matrix we just found to transform the general x, y, z vector. This operation is shown in the aforementioned image file attached to this message.

From looking at this image file, we can ascertain the following equations for x', y' and z' (where 'a' is the number of degrees to rotate about the y-axis and 'b' is the number of degrees to rotate about the x-axis (counter-clockwise)):

x' = xCos(a) + ySin(a)Sin(b) + zSin(a)Cos(b)
y' = yCos(b) - zSin(b)
z' = -xSin(a) + yCos(a)Sin(b) + zCos(a)Cos(b)

These are identical to what you found, thus implying that your earlier mistake in multiplying the matrices was most likely simply a typo.

I hope this helps,

Regards,

Silvercord
02-28-2003, 08:32 AM
Yes that is identical to what I had myself. Sorry about the way I posted my matrices, if I have to do it again I'll make an image for you so it's easier to read. You have been really really really (^infinity) helpful. I was surprised that you replied so fast and you really know what you're talking about :)

I haven't got this working yet (doesn't seem to do the rotations correctly) but I am trying to plug it into code right now. Like I said I'll upload the results.
Thanks, talk to you later.

rahaydenuk
02-28-2003, 08:42 AM
Originally posted by Silvercord
Yes that is identical to what I had myself. Sorry about the way I posted my matrices, if I have to do it again I'll make an image for you so it's easier to read. You have been really really really (^infinity) helpful. I was surprised that you replied so fast and you really know what you're talking about :)

I haven't got this working yet (doesn't seem to do the rotations correctly) but I am trying to plug it into code right now. Like I said I'll upload the results.
Thanks, talk to you later.

OK, good luck, I'll look forward to seeing it!

If you need any more assistance, don't hesitate to ask!

One thing, which could be causing problems... ensure that you are feeding the trig functions the correct format argument (i.e. check whether you should be using degrees or radians and if you're using the correct one), this can be a very elusive bug, if you haven't met/aren't used to using radians.

Regards,

Silvercord
02-28-2003, 09:05 AM
Yes I had already implemented rotating the view vector and camera position (third person) as well as the actual model about the y axis. Obviously this involves both radians and degrees (radians for rotating the views, degrees for rotating the model). Plus we are doing radians heavily in math right now, so I'm really all set with that :)

I am trying to plug this into code. I have been trying to get this working for 40 mins or so but this just does not work. Is there any problem with order here? Should I add any parenthesis anywhere? This really should be working, but it doesn't.

Dir = View - Position; //this is the direction
RotDir.x = (Dir.x * cosYTheta) + (Dir.y * sinYTheta * sinXTheta) + (Dir.z * sinYTheta * cosXTheta);
RotDir.y = (Dir.y * cosXTheta) - (Dir.z * sinXTheta);
RotDir.z = (Dir.x * -sinYTheta) + (Dir.y * cosYTheta * sinXTheta) + (Dir.z * cosYTheta * cosXTheta);

EDIT: this is how I derived the number of degrees and radians to perform the rotations. Everything worked for rotations about just the Y axis.

YRotation += ((360 * XDeviation) / SCREEN_WIDTH);
XRotation += ((360 * YDeviation) / SCREEN_WIDTH);
float YDeviation = (MiddleY - MousePos.y) / 2;
float XDeviation = (MiddleX - MousePos.x) / 2;

float XDegRad = ((2 * PI) * XDeviation) / SCREEN_WIDTH;
float YDegRad = ((2 * PI) * YDeviation) / SCREEN_WIDTH;

rahaydenuk
02-28-2003, 09:18 AM
Originally posted by Silvercord
Yes I had already implemented rotating the view vector and camera position (third person) as well as the actual model about the y axis. Obviously this involves both radians and degrees (radians for rotating the views, degrees for rotating the model). Plus we are doing radians heavily in math right now, so I'm really all set with that :)

I am trying to plug this into code. I have been trying to get this working for 40 mins or so but this just does not work. Is there any problem with order here? Should I add any parenthesis anywhere? This really should be working, but it doesn't.

RotDir.x = (Dir.x * cosYTheta) + (Dir.y * sinYTheta * sinXTheta) + (Dir.z * sinYTheta * cosXTheta);
RotDir.y = (Dir.y * cosXTheta) - (Dir.z * sinXTheta);
RotDir.z = (-Dir.x * sinYTheta) + (Dir.y * cosYTheta * sinXTheta) + (Dir.z * cosYTheta * cosXTheta);

EDIT: this is how I derived the number of degrees and radians to perform the rotations. Everything worked for rotations about just the Y axis.

float YDeviation = (MiddleY - MousePos.y) / 2;
float XDeviation = (MiddleX - MousePos.x) / 2;

float XDegRad = ((2 * PI) * XDeviation) / SCREEN_WIDTH;
float YDegRad = ((2 * PI) * YDeviation) / SCREEN_WIDTH;

What do MiddleY and MiddleX represent?

Regards,

Silvercord
02-28-2003, 09:19 AM
MiddleX and MiddleY are the screen width and height divided by two. it is the center of the screen in screen coords. note that when using getcursorpos and setcursorpos those screen coordinates are setup like a regular cartesian system. the point 0,0 is actually in the middle of the screen. for everything else I think the positive y goes down the screen and 0, 0 is the top left corner.
SetCursorPos(MiddleX, MiddleY); //sets cursor to exact middle of screen

static float MiddleX = SCREEN_WIDTH / 2;
static float MiddleY = SCREEN_HEIGHT / 2;

SCREEN_WIDTH and SCREEN_HEIGHT are #define'd compiler directives passed into the function that sets up the resolution.

If there is anything else that I didn't explain good enough please ask me.

#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768

rahaydenuk
02-28-2003, 10:20 AM
Originally posted by Silvercord
MiddleX and MiddleY are the screen width and height divided by two. it is the center of the screen in screen coords. note that when using getcursorpos and setcursorpos those screen coordinates are setup like a regular cartesian system. the point 0,0 is actually in the middle of the screen. for everything else I think the positive y goes down the screen and 0, 0 is the top left corner.
SetCursorPos(MiddleX, MiddleY); //sets cursor to exact middle of screen

static float MiddleX = SCREEN_WIDTH / 2;
static float MiddleY = SCREEN_HEIGHT / 2;

SCREEN_WIDTH and SCREEN_HEIGHT are #define'd compiler directives passed into the function that sets up the resolution.

If there is anything else that I didn't explain good enough please ask me.

#define SCREEN_WIDTH 1024
#define SCREEN_HEIGHT 768

I'm not sure exactly what your code is trying to do, so I've written a quick snippet showing how I'd do it (this would be repeated each time the scene is rendered).

I'm assuming as you said that the mouse cursor co-ordinate system is cartesian in nature with the +y-axis running up the screen, and the +x-axis running to the right.

float yaw = 0.0f, pitch = 0.0f;
float oldxpos = 0.0f, oldypos = 0.0f;
float xdisp, ydisp;

//all we are concerned with is the mouse's displacement since last render
xdisp = MousePos.x - oldxpos;
ydisp = MousePos.y - oldypos;

yaw += -(xdisp * c); //use -ve as rotations are anti-clockwise
pitch += -(ydisp * c);

//you may want to add a couple of simple loops
//here to make the yaw and the pitch modulus 2*pi.
//This would just prevent the values of yaw and pitch from
//getting too large (or too small) for the float type.

//store positions of mouse for next render
oldxpos = MousePos.x;
oldypos = MousePos.y;

//You then need to transform the position of all objects (rotate them) in your scene through the following:
object.x = object.x * cos(yaw) + object.y * sin(yaw) * sin(pitch) + object.z * sin(yaw) * cos(pitch);
object.y = object.y * cos(pitch) - object.z * sin(pitch);
object.z = -object.x * sin(yaw) + object.y * cos(yaw) * sin(pitch) + object.z * cos(yaw) * cos(pitch);

The value 'c' in the above code is a constant, which you will need to experiment with. It depends on many things such as screen size and your personal feeling as to how fast the rotation should be. Try something like 0.003 to start. You should then maybe form a formula for 'c', which uses the screen size, so as to account for running this application on different size screens. This should all be possible by trial and error.

The last part of the code, which refers to some structure 'object' should naturally be repeated for all objects in your scene.

You must also remember that you need to implement a projection transformation to map the 3D scene on to your 2D screen, and you would also need another translation transform if you intend to move the camera.

Good luck,

Regards,

Silvercord
03-01-2003, 06:22 PM
I am getting frustrated, everything I do doesn't actually work. I'm plugging into an application that previously utilized rotation about the Y axis. When I try plugging in the equations for combining the X and Y rotation matrices, it does not work as it should. Can you look at this code and tell me if anything does not look right? If there is nothing wrong here, then I will simply look elsewhere in the code for the source of the problem.

RotDir.x = (Dir.x * cosYTheta) + (Dir.z * cosXTheta) + (Dir.y * sinYTheta * sinXTheta);
RotDir.y = (Dir.y * cosXTheta) - (Dir.z * sinXTheta);
RotDir.z = (Dir.z * cosYTheta * cosXTheta) - (Dir.x * sinYTheta * sinXTheta);

rahaydenuk
03-02-2003, 04:43 AM
Originally posted by Silvercord
I am getting frustrated, everything I do doesn't actually work. I'm plugging into an application that previously utilized rotation about the Y axis. When I try plugging in the equations for combining the X and Y rotation matrices, it does not work as it should. Can you look at this code and tell me if anything does not look right? If there is nothing wrong here, then I will simply look elsewhere in the code for the source of the problem.

RotDir.x = (Dir.x * cosYTheta) + (Dir.z * cosXTheta) + (Dir.y * sinYTheta * sinXTheta);
RotDir.y = (Dir.y * cosXTheta) - (Dir.z * sinXTheta);
RotDir.z = (Dir.z * cosYTheta * cosXTheta) - (Dir.x * sinYTheta * sinXTheta);

No, it should be:

object.x = object.x * cos(y) + object.y * sin(y) * sin(x) + object.z * sin(y) * cos(x);
object.y = object.y * cos(x) - object.z * sin(x);
object.z = -object.x * sin(y) + object.y * cos(y) * sin(x) + object.z * cos(y) * cos(x);

Where y is the angle about the y-axis and x is the angle about the x-axis.

Regards,

Silvercord
03-04-2003, 09:20 AM
I have finally semi-gotten this to work. I am sorry to say that I did not get it working with combining the rotations about the X and Y axes. Instead I rotated the view about the current strafe vector then added the rotation about the Y axis. This works when everything is in the positive direction, but as soon as I turn around and face the camera everything gets all screwed up. Do I need to cap the amount that I can rotate in a single scene or something, or is there just something flawed with my application that I am un aware of? I guess I need to just keep experimenting with this until it's perfected.

I'm including the binary with all of the necessary data files (I have to break it up across multiple zip files). Just make sure you put everything in the same folder before you run the executable. I'm not including the source right now (too much stuff at once).

Silvercord
03-04-2003, 09:20 AM
bitmaps

Silvercord
03-04-2003, 09:20 AM
and finally the model