# transformation matrix and camera

If I have a matrix( m ) that contains the transformations on a scene, is it possible to find the direction the camera is facing in that scene? TIA.

-Drew

Hi !

Take a normalized vector that is pointing along the Z axis (same as the camera), muiltiply it with the matrix and you have the direction the camera is facing.

Mikael

Alright, that makes sense. Now I have this matrix:
m m m m
m m m m
m m m m
m m m m

( m, m, m ) makes up the z-axis, ( m, m, m ) makes up the y-axis, relative to the camera.

I would assume then that ( m, m, m ) makes the x axis, relative to the camera.

Why then, in my code, when I try and print out the axis do the z, and y axis appear correctly, but the x axis seams to attempt to stay with the local coordinate system. Why does what I would assume is the x axis relative to the camera, appear to change magnitude( I am ploting a normalized vector from the origen) and direction when I rotate the local axis, but the other two remain where I believe they should be?

-Drew

mikael_aronsson is incorrect. To get the camera’s direction vector in world space, you want to find what -Z is when it is transformed back into world space – you multiply (0,0,-1) by the inverse of the view matrix.

Fortunately, that’s the same as this vector: ( -m, -m, -m ).