# LOS Vector Problem

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

## Recommended Posts

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!

##### Share on other sites
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.

##### Share on other sites
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!

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 11
• 29
• 15
• 41
• ### Forum Statistics

• Total Topics
634838
• Total Posts
3019568
×