# Getting the Right Vector from the Forward Vector

I'm currently working on a small Camera (ArcBall) and I finally am starting to understand how it will work.

I will first create a basic View Matrix using a LookAt function.

Then, I will send the Camera Position and the Camera Target to a function which will:

1: Calculate the Vector of (Camera Position - Camera Target)

2: Rotate this vector by X Pitch 3: Rotate the same vector by Y Yaw

This will determine the new Camera position. Now I need to find the Up Vector to be able to use LookAt() so I need to do the cross product of the forward and the right vector to find the Up Vector.

4: I will do (Camera Target - Camera Position) and normalize it so this will be my new Forward vector

5: ??? I need to find the right vector. How can I find the Right vector if I do not have the Up vector?

If you see flaws with my ArcBall camera, tell me, I am new to OpenGl and I'm trying to learn.

• Have you completed High School mathematics? I ask because the manner in which any answer is presented, concisely or verbosely, mathematically sophisticated or naïve, depends on your background. – Pieter Geerkens May 19 '16 at 3:10
• Not really, well, High School yes but where I lived, we have never learned Matrices and Vector. Sorry ! – Gabriel Roy May 19 '16 at 3:20
• @GabrielRoy It will really be difficult to use OpenGL for 3D games without a good understanding of Linear Algebra, I strongly recommend learning everything you can about Vectors, Matrices, Transformations, and if you are so daring, Quaternions. – user5665 May 19 '16 at 5:17

For example, if I am looking forward along the z axis forwardVector = vec3(0,0,1), then I could have up be along the y axis upVector = vec3(0,1,0) and right therefore be along the x axis rightVector = vec3(1,0,0), or I could have up be along the -y axis upVector = vec3(0,-1,0) and therefore right would be along the -x axis rightVector = vec3(-1,0,0). Or I could even have 'up' be along the x axis upVector = vec3(1,0,0), which would mean that right is along the y axis rightVector = vec3(0,1,0). And so forth. No one "up" or "right" vector can be considered "correct" if all you have is a forward vector, without imposing some extra constraints on the system.