# Relationship between UVN, euler angles and target location, etc

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?

Okay I think that I found how to do thisâ€¦ here is what I came up with.

Case 1

We are interested in calculating the new target(center) point once the the pitch and/or the yaw has been changed. We use the above formula:

• N = ( cos(yaw)*cos(pitch), sin(pitch), sin(yaw)*cos(pitch) )

to derive a new N. Then we calculate the new target location in this way:

new_target = position - ||position - old_target|| * N, where || || is the magnitude of the vector

Case 2

We are interested in calculating the pitch and yaw of a vector given a change in the position (eye) and/or target(center) positions.

We use the following formulae,

Calculate D = position - new_tgt

yaw = atan2( Dz , Dx )
pitch = atan( Dy / sqrt(Dx^2 + Dz^2) )

I believe these are correct given all of the above information.