Vector Matrix Toolset

Basic operators to work on vector3 and 4x4 transform matrices. Each pixel have its own vector and matrix data. Building blocks to create more complete tools.

Updated: 19 February 2018

Author: mapoga

Compatible Nuke versions: 7.0 or later

Compatibility:

Introduction The toolset is seperated into 2 categories. One to operate on vectors3 and one to operate on 4x4 transformation matrices.
Every pixel can be worked on independently because each can have its own vector and matrix data.

Vector

Vector data is expected to be in the layer rgb.
(r, g, b) = (x, y, z)
Operations like vector addition, substraction, multiplication and division can be done with a standard merge or merge expression node.

Vector_magnitude
Vector_Normalized
Vector_Dot
Vector_Cross
Vector_Apply_Matrix

 

Matrix

Matrix data is expected to be in the layers; matrix0, matrix1, matrix2 and matrix3.

Layers are automatically created by the nodes.


The transformation matrix is stored as followed:
matrix0: [0, 1, 2, 3,
matrix1: 0, 1, 2, 3,
matrix2: 0, 1, 2, 3,
matrix3: 0, 1, 2, 3]


Matrix_Identity
Matrix_Invert
Matrix_Product
Matrix_Transform
Matrix_Translate
Matrix_Rotate
Matrix_Scale
Matrix_Transpose
Matrix_Determinant
Matrix_3x3_det
Matrix_2x2_det

 

 

Vector operators


Vector_Magnitude

Returns the magnitude of a vector. In other words, the vector's length.

The resulted output is repeated to fill up the output vector.

input: vector

output: vector

 

Vector_Normalize

Returns the normalized vector.

Scaling the vector so that its length equal 1.

input: vector

output: vector

 

Vector_Dot

Returns the dot product between 2 vectors.

The resulted output is repeated to fill up the output vector.

inputs: vectorA, vectorB

output: vector

 

Vector_Cross

Returns the cross product between 2 vectors.

input: vectorA, vectorB

output: vector

 

Vector_Apply_Matrix

Returns a new vector resulted by the input vector multiplied by the input matrix.

inputs: vector, matrix

output: vector

 

Matrix operators

 

Matrix_Identity


Returns an 4x4 identity matrix.

The input bg is used to give a format to the matrix.

input: bg

ouput: matrix

 

Matrix_Invert

Returns the inverted input 4x4 matrix.

input: matrix

output: matrix

 

Matrix_Product

Returns the dot product of matrixB * matrixA.

The matrix order is very important as switching A and B will give different results.

inputs: matrixB, matrixA

output: matrix

 

Matrix_Transform

Retuns the input 4x4 matrix transformed by the the node's knobs.

If no matrix is given, the transformations will be made on a identity matrix.

input: matrix

output: matrix

 

Matrix_Translate

Returns the input 4x4 matrix translated by the input vector.

inputs: matrix, vector

output: matrix

 

Matrix_Rotate

Returns the input 4x4 matrix rotated by the input vector.

inputs: matrix, vector

output: matrix

The rotation unit knob specify the rotation unit(degrees or radians) of the input vector.

The rotation order knob specify the order in which the axes are rotated

 

Matrix_Scale

Returns the input 4x4 matrix scaled by the input vector.

inputs: matrix, vector

output: matrix

 

Matrix_Transpose

Returns the input 4x4 matrix transposed.

Values of the matrix are mirrored diagonally.

inputs: matrix

output: matrix

 

Matrix_Determinant

Returns the determinant of the input 4x4 matrix.

The resulted output is repeated to fill up the output vector.

inputs: matrix

output: vector

 

Matrix_3x3_det

Returns the determinant of the input 3x3 matrix.

The resulted output is repeated to fill up the output vector.

Utility operator used by the Matrix_Determinant and Matrix_Invert operators.

inputs: matrix

output: vector

 

Matrix_2x2_det

Returns the determinant of the input 2x2 matrix.

The resulted output is repeated to fill up the output vector.

Utility operator used by the Matrix_3x3_det, Matrix_Determinant and Matrix_Invert operators.

inputs: matrix

output: vector

Sign in or register to download or rate.