# Orbit Rotation to Unit Directional Vector

Hello all.
In my program, my light sources are defined by:

vec3 location
vec3 direction (unit directional vector. ie. 0,0,1 for looking down the Z axis away from the screen)
vec3 color

My third-person camera is defined by:

vec3 view (location of what it is looking at)
vec3 distance (distance from the view)
vec3 orbit (rotation around the view in radians)
vec3 up (the ‘up’ vector)

These values for the camera become a mat4 (perspective matrix) and are passed to the vertex shader as a uniform.

The camera and the lights work fine.

As you can see my camera’s facing is defined initially by its orbit and up vectors and ultimately by the resulting mat4 perspective matrix.

My question is, how can I mathematically obtain a unit directional vector from either; the mat4, or the orbit vector.
The reason I want to do this is that I have a light that I want to face the same direction as the camera.

I’m not sure I’ve understood correctly what you have asked.

Which directional versor?
The forward direction of the camera? In this case it’s simple. You can extract this vector easily from the perspective matrix, as it has the direction of the near plane’s normal.
Or more easily: forward = normalize(viewTarget - locationCamera)

But of course it’s not what you asked for, right?