Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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).

share|improve this question
    
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. –  Xan 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
1  
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

1 Answer 1

up vote 0 down vote accepted

Instead of moving camera, why not move your object and keep the camera fixed?

share|improve this answer
    
Because, it is kind of hard to see something across the world when you are 300 feet away. –  Xan Jun 9 '11 at 19:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.