LOS Vector Problem

Started by
1 comment, last by Supernat02 18 years, 4 months ago
Hi, I have the following problem and would appreciate any help. Thanks. I have a spaceship with 6 degrees of freedom, indicated at any given time by yaw, pitch, and roll angles. I have a camera attached to the spaceship with the ability to move in a limited FOR. For simplicity, the camera is at the center of the spaceship and doesn't have the spaceship model in its view. I don't keep track of the camera's yaw, pitch, roll angles with respect to the spaceship, but I do calculate them with respect to the global coordinate system (XYZ axes). I also know the global az/el values. What I want to know is the az/el values with respect to the spaceship. For instance, no matter which way the spaceship is facing or rotated toward, the camera is still 10 degrees down and 10 degrees right because it is attached to the spaceship. I know it has something to do with a transformation. Please tell me if my idea is right or wrong if you can. I take the global az/el values, create a vector from them, transform that vector by the inverse of the spaceship's roll/pitch/yaw matrix, then convert the new vector back to az/el. Is it that simple? Do I have the order of rotations right? Thanks!
Chris ByersMicrosoft DirectX MVP - 2005
Advertisement
You have the "global" orientations of the spaceship, S, and the camera, C, and you are looking for the orientation of the camera relative to the spaceship -- a value of M that satisfies this equation: S = CM (assuming column vectors). Solve for M:
    S = CM    C-1S = C-1CM    C-1S = M 
BTW, with 6 DOF, you are going to run into problems (specifically "gimbal lock") if you keep track of your spaceship's and camera's orientations using yaw, pitch, and roll.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
I don't use yaw, pitch, and roll to keep track of it. They are calculated from direction cosines. The approach I wrote (pretty sure it's the same equation you suggested) worked.

Thanks!
Chris ByersMicrosoft DirectX MVP - 2005

This topic is closed to new replies.

Advertisement