# Find forward vector for node different from camera forward vector

Hi all,

I am trying to extract the forward vector from 4x4 transformation matrix.
I have two forms of calculation one is for nodes in the scene graph and other is for camera.

This is how I calculate transformation matrix for node.

``````

// Matrix44 is a float

Matrix44 nodeTranslationMat; // translation matrix for node

Matrix44 nodeRotationMat; // rotation matrix for node

Matrix44 transformationMatrix= nodeTranslationMat* nodeRotationMat; // transformation matrix

``````

And this is how I do it for camera

``````
Matrix44 cameraTranslateMat; // translation matrix for camera

Matrix44 cameraRotationMat; // rotation matrix for camera

Matrix44 transformationMatrix= cameraRotationMat* cameraTranslateMat; // transformation matrix, note - multiplication order is different form node

``````

And then for the camera forward vector I can extract using above transformation matrix like

``````Vector3f forwardVector = Vector3f(transformationMatrix, transformationMatrix, transformationMatrix);
``````

But If I do this above to find the forward vector for node it’s not works.

Changing the order of rotation and translation makes for two different transformations … reasonably with two different z-vectors in the output transformation-matrix.

After doing visual experiments, I realized that the forward vector for node can be calculate as

`````` Math::Vector3f(transformationMatrix, transformationMatrix, transformationMatrix);
``````

For camera, forward vector is

``````Math::Vector3f(transformationMatrix, transformationMatrix, transformationMatrix)
``````

So if the multiplication order is different

``````Matrix44 nodeTransformationMatrix= nodeTranslationMat* nodeRotationMat;
Matrix44 cameraTransformationMatrix= cameraRotationMat * cameraTranslationMat;
``````

forward vector calculation should also different?

Sorry I am trying to learn the basics.

deshan,
have you checked the visual differences between the two transformations?
If you do two nodes, one with each transformation … you’ll see why you may not be able to match up the two ‘forward’ vectors.
A ‘forward’ vector is not an inherent quality of a matrix … it may fit the z-vector for the camera, but did you make your node in coordinates, where the z-vector is ‘forward’?