To create matrix 4x4 :
mtx=nuke.math.Matrix4()
print mtx
--> {2.379e-17, 0, 5.7439e-20, 0, 5.65215e-22, 0, 3417.91, 0, 0, 0, 0, 0, 0, 0, 6.27864e-24, 0}
mtx.makeIdentity()
print mtx
--> {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}
mtx[12]=3
mtx[13]=5
print mtx
--> {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3, 5, 0, 1}
element #12,#13,#14 = dx,dy,dz (translate x/y/z)
The mapping (relationship) between the matrix4 class and matrix knob is as follow :
(note : see below, the translate element is colored in red just for example purpose only )
matrixknob :
00 - 01 - 02 - 03
10 - 11 - 12 - 13
20 - 21 - 22 - 23
30 - 31 - 32 - 33
matrix class :
{
00,01,02,03,
01,11,21,31,
02,12,22,32,
03,13,23,33
}
so dx/dy/dz respectively is element 03/13/23.
To access this element in nuke, we use 2d index :
matrixknob.value(0,3) for
03
matrixknob.value(1,3) for
13
matrixknob.value(2,3) for
23
in nuke matrix class/object , we access this by linear indexing (1d index)
mtx[12] for
03
mtx[13] for
13
mtx[14] for
23
- end-