OpenSCAD language has a rare leniency with programming errors. That is nice
but dangerous if the its behavior is not properly documented. I found by
mistake that multmatrix() accepts 3x3 matrix as well. And do the expected
linear transform. So, if R is a 3x3 rotation matrix, multmatrix(R) cube()
will rotate correctly the cube. More than that, it accepts even non-uniform
"matrices" like:
M = [ [ [ -1, 0, 0, 0], [0] , [0,0,-1] ];
to do a 90 degree rotation about y axis. It seems that multmatrix() fill out
the blanks with the corresponding 0's and 1's borrowed from the identity
matrix in this case. Who knows?
Although this last example is a bit odd, it would be nice to allow the use
of 3x3 matrices in multmatrix() as a feature and not just as a complacent
work around. But this should be documented to become a feature. Otherwise we
cannot rely on it.
--
View this message in context: http://forum.openscad.org/multmatrix-argument-tp17983.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Nice catch. I read somewhere --- not specefically for OpenScad but as a
general description --- that feeding multmatrix with a 3x3 is much faster
than with a 4x4. So if OpenScad does follow that behavior, it'd be nice to
have 3x3 for multmatrix as a regular argument when 4x4 is not needed.
View this message in context: http://forum.openscad.org/multmatrix-argument-tp17983p17984.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
To see the code with default values, just display the CSG tree.
M = [ [ -1, 0, 0, 0], [0] , [0,0,-1] ];
multmatrix(M) cube();
gets
group() {
multmatrix([[-1, 0, 0, 0], [0, 1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]]) {
cube(size = [1, 1, 1], center = false);
}
}
--
View this message in context: http://forum.openscad.org/multmatrix-argument-tp17983p17985.html
Sent from the OpenSCAD mailing list archive at Nabble.com.