rotate a vector by 90 degrees

Started by
5 comments, last by mark-w 18 years, 6 months ago
Hi everyone, I have a set of world axes, x,y,z. I have a vector with magnitude 0/0/-1 meaning it is traveling down the z axis with no change along the x or y axis. How can I go about rotating this vector 90 degrees around the y axis? If someone could explain that, is there then some resource that could show how to rotate a vector along any of the main world axes (x,y,z)? Thanks, Mark
Advertisement
The result will be (-1,0,0) or (1,0,0) depending on the direction of rotation. What you need is a rotation matrix. This site has some information on those (click the word Articles below the word Resources below the GameDev.net logo).
Hello,

you don't even need a rotation matrix in this case.
You can take the cross product between the -z vector and a -y vector and then you've got a -x vector --> a difference of 90 degrees :)
Hi guys,

I only need to know how to rotate by 90 degrees around
either the x, y, or z axis. Never any other degree, or
around any non perpendicular axis. So can I lookup how
to do the 'cross product' and I'll be ok?

Thanks,
Mark
In a right-handed coordinate system, the rotations are as follows:

90 degrees CW about x-axis: (x, y, z) -> (x, -z, y)
90 degrees CCW about x-axis: (x, y, z) -> (x, z, -y)

90 degrees CW about y-axis: (x, y, z) -> (-z, y, x)
90 degrees CCW about y-axis: (x, y, z) -> (z, y, -x)

90 degrees CW about z-axis: (x, y, z) -> (y, -x, z)
90 degrees CCW about z-axis: (x, y, z) -> (-y, x, z)

If you're using a left-handed coordinate system, simply switch 'CW' with 'CCW' above.
Hi Aprosenf,

Thanks for those shortcuts, they work perfectly in
my situation. I would like to know if there is also
a set of rules for knowing when to rotate clockwise
vs counter clockwise about the axis.

If my vector is:

(0,0,-1) pointing straight down the Z axis

and I want to rotate it 90 degrees about the y axis
so that it is now:

(1,0,0) pointing straight up the X axis

how can I 'know' that I needed to rotate clockwise
instead of counter clockwise? What makes a rotation
clockwise vs counter clockwise?

Thanks,
Mark
Shouldn't:

90 degrees CW about x-axis: (x, y, z) -> (x, -z, y)
90 degrees CCW about x-axis: (x, y, z) -> (x, z, -y)

be swapped for the right-handed coordinate system? I
tried a few examples, and the rotations about the y
and z axis seem correct, but they seem backwards for
rotation around the x. Can anyone verify this?

Thanks,
Mark

[Edited by - mark-w on November 15, 2005 2:35:39 PM]

This topic is closed to new replies.

Advertisement