mathematical functions for scripting in LDCad


RE: mathematical functions for scripting in LDCad
#8
(2018-03-15, 14:05)Joscha Wrote: Coming back to the matrix type. You describe that it is a 4x4 matrix initialised as identity matrix. But for the location and orientation only 12 elements are used. Do the four remaining elements contain information?

The 12 elements are what is used in LDraw "type 1" lines. It's a position and 3x3 rotation matrix. Internally this is stored in a 4x4 matrix but one column (or row depending how you look at it) is (or should be) always 0 0 0 1 as it assumes the matrices only contain a rotation and translation.

ps: I noticed an error in my code which works only because of a fluke:
Code:
local matrix=ldc.matrix()
matrix:setTranslate(center:getInverted())
matrix:mulAB(rotation)
matrix:mulAB(center)
should be
Code:
local matrix=ldc.matrix()
matrix:setTranslate(center:getInverted())
matrix:mulAB(rotation)
matrix:mulTranslateAB(center)
mulAB with a matrix using a vector in its constructor acts like a translate as it is basically an alias, but it can be very confusing.
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: mathematical functions for scripting in LDCad - by Roland Melkert - 2018-03-15, 18:13

Forum Jump:


Users browsing this thread: 2 Guest(s)