Archived

This topic is now archived and is closed to further replies.

calculating the Y and X axis from the Z axis

This topic is 5043 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

ok i tried to work this out for a few hours, but i couldnt figure it out. I basically want to be able to calculate the X and Y axis, given the Z and a rotation around the Z (roll angle). so the cross product of the resulting 2 vectors should equal the z vector has anyone got any ideas?

Share on other sites
Construct the orientation without the roll angle, and then concatenate a matrix that represents that rotation about z.
Vec3 y_axis(0,1,0);Vec3 x_axis = y_axis.cross(z_axis).normalize();y_axis = z_axis.cross(x_axis);// construct the orientation without roll.Matrix3 orientation(x_axis, y_axis, z_axis);// construct a matrix that represents a rotation about z.Matrix3 rotate_about_z(Vec3(0,0,1), roll_angle);// concatenate.orientation = orientation * rotate_about_z;

[edited by - ajas95 on February 20, 2004 12:16:32 PM]

[edited by - ajas95 on February 20, 2004 12:18:08 PM]

Share on other sites
quote:
Original post by ajas95
Construct the orientation without the roll angle, and then concatenate a matrix that represents that rotation about z.
Vec3 y_axis(0,1,0);Vec3 x_axis = y_axis.cross(z_axis).normalize();y_axis = z_axis.cross(x_axis);// construct the orientation without roll.Matrix3 orientation(x_axis, y_axis, z_axis);// construct a matrix that represents a rotation about z.Matrix3 rotate_about_z(Vec3(0,0,1), roll_angle);// concatenate.orientation = orientation * rotate_about_z;

That won''t work when the zaxis is equal to (0,1,0). because in your line:
x_axis = y_axis.cross(z_axis).normalize()
you will get
(0,1,0) x (0,1,0) = (0,0,0) and you can''t normalize (0,0,0), you get a division by 0...

But anyway, there is no solution to your question... a rotation without a frame of reference is meaningless, you say "given the Z and a rotation around the Z"... well you first have to define what direction 0 degrees represents...

• Forum Statistics

• Total Topics
628644
• Total Posts
2984012

• 9
• 9
• 10
• 21
• 20