# Compute "up" and "right" from a direction

I have a camera class that is missing some functionality.

I need to give it the ability to, given a direction, or a point to look at, will rotate the camera left/right and up/down to look at this point or along this direction, without causing gimbal lock.

lets, say I move the camera to (10,10,10).

I want the camera to point at (0,0,0).

By normalizing the vector , I find that the direction I want to look along is (-0.577,-0.577,-0.577). We'll call this "Forward".

What I want to be able to do, is compute the local "Up" and "Right" vectors which are perpendicular to Forward.

How do I do this?

• You should use quaternions to avoid gimbal lock Commented Apr 8, 2017 at 19:42
• gamedev.net/topic/… use the cross product Commented Apr 8, 2017 at 20:01

First, keep in mind that you need some other piece of information. A direction by itself has no intrinsic "up" direction. You'll typically have some kind of global "up" defined by your game, usually (0,+1,0) or the like.