I want to scale normals (Point3 values) so I believe I have to create a scale matrix then use its inverse transpose to scale the normal. This is what I ussually do with 4x4 homogeneus matrixes. However maxscipt uses 3x3 matrix and a 4th row for translation. How can I do the transformation ? Max script allow me to create a scale matrix and invert it. However it says there is no transpose method for matrix3 values.
This is the code that fails:
smat = scaleMatrix [1, 2, 3]
smat = inverse smat
smat = transpose smat -- No transpose function for matrix3
p = p * smat
Also I wonder if normals change direction even if the surface that they belong to get scaled non uniformly. My intiution says no :)
I used BigMatrix type in maxscript. However it needs a matrix * Point3 multiplication method. I wrote it aswell.
-- constructing the scale matrix
smatrix = bigMatrix 3 3
smatrix[1][1] = sx
smatrix[2][2] = sy
smatrix[3][3] = sz
invert smatrix
transpose smatrix
function bigMulti m v =
(
local p = [0, 0, 0]
p.x = m[1][1] * v.x + m[2][1] * v.y + m[3][1] * v.z
p.y = m[1][2] * v.x + m[2][2] * v.y + m[3][2] * v.z
p.z = m[1][3] * v.x + m[2][3] * v.y + m[3][3] * v.z
p = normalize p
return p
)
-- lets say we want to transform this normal [0, 1, 0]
normal = [0, 1, 0]
normal = bigMulti smatrix normal