I am certain this has come up but I have not bean able to find a satisfactory answer partly because there are so many different versions of this online. I am hoping someone might be able to assist. Here is what I have so far.
Camera has a position(eye) where it is located and a target(center) where it is looking at. Also a camera has a pitch or elevation angle (origin: xz plane, measured positive clockwise -downwards - ) and a yaw or bearing angle (origin X+ axis, measured positive anticlockwise towards Z+). All angles are in radians.
I am assuming that yaw=-90 is pointing in the Z- direction, pitch = -90 is pointing up and +90 pointing down.
So I am using the UVN coordinate system defined as follows:
- N = Normalized (position - target)
- U = Normalized (WorldUp* x N) *WorldUp usually = (0,1,0)
- V = N x U
Using the following equations I can compute a new version of N given a certain value of the pitch and the yaw:
- N = ( cos(yaw)*cos(pitch), sin(pitch), sin(yaw)*cos(pitch) )
I want to be able to change the pitch (elevation) and yaw (bearing) of my camera, either by rotating by a certain angle or setting them in absolute terms and calculate what is my new target location (i.e. the coordinates of the location I am now looking at)?
Equally, I am interested in being able to change the position (eye) and/or target(center) of the camera and calculate the new pitch and yaw values?