# 3d trigonometry

• 03-19-2010, 07:04 PM
deepthought
3d trigonometry
i am trying to figure out how to move a camera around in jogl. the function to set the camera takes the arguments 0f x position,y position,z position, x coordinates to look at, y coordinates to look at, and z coordinates to look at. if i know the x and y angles that my camera is at, how i calculate the change in x, y, and z coordinates, and which coordinates to look at?
• 03-20-2010, 12:32 PM
JosAH
Quote:

Originally Posted by deepthought
i am trying to figure out how to move a camera around in jogl. the function to set the camera takes the arguments 0f x position,y position,z position, x coordinates to look at, y coordinates to look at, and z coordinates to look at. if i know the x and y angles that my camera is at, how i calculate the change in x, y, and z coordinates, and which coordinates to look at?

Let (xc, yx, zc) be the location of the camera and let (xt, yt, xt) be the target position (where the camera is looking at). Translate over position T, so the camera is at position (xc-xt, yt-yc, zc-zt) and looking at (0, 0, 0) (the origin). You can rotate this new point however you want (and find new x, y, z, coordinates for the camera). When you're done translate the new coordinates back over position T (see above). Google is your friend w.r.t. 3D rotation matrixes.

kind regards,

Jos
• 03-21-2010, 02:56 AM
deepthought
sorry man, but that's right over my head. the look at function takes (posx,posy,posz) as where the camera is,(lookx,looky,lookz) as where you're looking at, and(headx,heady,headz) as where the top of the head is pointing. how do i use this function if i know (x position,y position, zposition,yaw,pitch,roll) ? please send code because i have no idea how to implement it myself.