# Keeping camera and focal point relative after translation

I'm creating a program that has a 3D view. The 3D world uses three vectors (X,Y,Z). Now, the way the camera works is by having two points, the focal point and the camera. The camera is set to look at the focal point at all times.

I want it so when my users press D, the camera and focal point should move to the right relative to their current position. (A = Left, W = Forward, S = Backword)

Imagine you are holding a long stick with a ball on the end. You would be the camera and the ball would be the focal point. Now, no matter what direction you face (assuming you keep the stick straight out), moving "right", the focal point will move the same distance as you do, while, to you, you are moving to the right. Looking up will also have the stick point up. Basically, the ball goes where ever you are looking.

Givens:

I know the XYZ position of both the Camera and the Focal Point.

Now, assuming I want to add, say 2, to the position of both objects to move them right, how would I do this?

I started doing something odd with slope and stuff but it didn't end up working like I wanted. Basically, I was trying to find the slope that would create a perpendicular line, etc.

Anyways, this may sound like something that would end up in GameDev or something but I just need the math for it. The only reason why I can't wrap my head around it is because I'm dealing in 3D instead of 2D (like I've been learning in school).

-
Just curious, I know nothing about games. What is wrong with adding $2$ to each of the first ("$x$") coordinates for moving $2$ right, and so on for other motions. Would the $3$-D program take care of the rest? By the rest I mean the $2$-D rendering. – André Nicolas Jun 9 '11 at 21:23
@user6312 The problem is, the camera won't necessarily be oriented like that, they could easily be at an angle. – Xander Lamkins Jun 10 '11 at 2:20
Knowing the position of the camera and the focal point is not enough to determine the projection. The camera also needs to have a sense of "up". Is there something that tells the camera which direction is up? The idea of "right" is dependent on both "forward" and "up". – robjohn Sep 8 '11 at 12:10
You could describe this problem with two vectors an and orientation. The position of the camera $(x,y,z)_C$. The direction that the camera is pointing and the distance to the focal point (this is another vector) $(x,y,z)_F$. If you fix the distance to the focal point then you could describe this in terms of two angles. A third angle would be the rotation of the camera. This you need to define in terms of some reference (such as up - and a projection is involved). Transformations on the three angles won't commute but smooth arcs can be designed in that space. – Alice Sep 8 '11 at 12:59