1
$\begingroup$

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

  • 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.2011-09-08

1 Answers 1

0

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

  • 1
    Because, it is kind of hard to see something across the world when you are 300 feet away.2011-06-09