This is a problem I am having for an OpenGL project. However, I felt it would be OK to post in this board, because it isn't Code specific at all, it has to do solely with math.
I need to calculate a location in 3D space that the camera will "look at", based on given x and y angles. NOTE: the angles are in radians.
So far I am calculating it like this:
pointy=sin(anglex);
pointx=sin(angley);
pointz=cos(angley);
for simplicity we will just assume the camera is at 0, 0, 0 and the location (pointx, pointy, pointz) is where the camera will be pointed at. The problem is with "pointz".
To sort of illustrate what the problem imagine that the camera is looking straight up. You can see from that code that it will calculate 1.0 for 'pointy' and it will calculate 0.0 for 'pointx'. However, because the pointz is based on the Y angle it will calculate 1.0 for 'pointz'. So the final point will be (0.0, 1.0, 1.0) As you can see this is not pointing directly up, it will be pointing at 45 degrees forward and up.
So basically I just need to know the actual MATH involved in calculating an new position based on an x and y angle.
The right man in the wrong place can make all the difference in the world.