# How to find the target position?

Ok I have to admit that my math class was like ages ago… but…

How can I calculate the camera target position:

I have XYZ: camera position

I have XYZ: angles in degree

how can I calculate the XYZ of the camera target position assuming that the distance is 1.0f?

Cheers,

you have the camera position§,
you have the normalized camera direction(D),
you have the distance(L),
so, the target position(T) is :

T = P + D * L;

I guess the D matrix is mysterious in the previous post, the original poster talked about angles in degrees. Let’s say we are in the XY plane and have a heading rotation in the plane H and a pitch rotation P upward. The camera roll angle doesn’t influence the target position. Given further the camera position as X, Y, Z, we get a target position:

Xt = X+cos(H)*cos§
Yt = Y+sin(H)*cos§
Zt = Z+sin§

The only thing worth noting is that you may have to convert your angles to radians (OpenGL uses degrees in glRotate, but the C math lib uses radians!!!) by multiplying with PI/180 beforehand, e.g.
H=h180/PI, P=p180/PI, where h and p are the angles expressed in degrees.