Doesn't seem to be returning the number I am looking for, I swapped the origin and target (player/camera) and got the same type of result each time. I probably should have been a bit more specific.
Origin X, Y, Z:
{-9176.93, 336.066, 91.83826}
Target X, Y, Z:
{-9195.183, 317.5946, 87.67601}
Code:
private float ComputeYaw(MyWoW.Position origin, MyWoW.Position target)
{
return (float)Math.Atan2(target.Y - origin.Y, target.X - origin.X);
}
//convert to deg.
yaw = (float)(180 / Math.PI) * ComputeYaw(cameraPos, myPos);
returns -134.65921
The result of this is correct only if the player is facing north, rotating the camera shows the yaw as a value between -pi and pi. When converted to degrees: 90 to the right, 180 on the opposite side and -90 (270) to the left.
This works as if the player was always facing north, so I guess I also need a way to take the player's facing into account? So that if the player was flying directly west and the camera was following in its default location (directly behind the player) 0 would be returned. I'm thinking that it should be pretty simple. I'll experiment some more.
Thank you so much for your help. +rep
EDIT:
Got it, while there might be a more elegant way to accomplish this:
rotation = (float)(ObjectManager.Me.R * (180 / Math.PI));
yaw = yaw - rotation
if (yaw < 0)
{
yaw = yaw + 360
}