mathematical functions for scripting in LDCad


RE: mathematical functions for scripting in LDCad
#17
(2018-03-14, 23:55)Roland Melkert Wrote: To rotate around another center you do indeed need to apply a translate, like so:

Code:
local center=ldc.vector(10, 0, 10) --some alternative center. local rotation=ldc.matrix() rotation:setRotate(45, 0, 1, 0) --e.g 45 deg rotate around y --build transformation matrix local matrix=ldc.matrix() matrix:setTranslate(center:getInverted()) matrix:mulAB(rotation) matrix:mulTranslateAB(center) --Apply it to brick(s), e.g the first one in the model local ref=ldc.subfile():getRef(1) local refMatrix=ref:getPosOri() refMatrix:mulAB(matrix) ref:setPosOri(refMatrix)

Roland, I have to come back to your code above. I applied it successfully. Thank you! But I do not understand the getInverted command. How to invert a vector? The command should be only for matrices, shouldn't it?
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: mathematical functions for scripting in LDCad - by Joscha - 2018-03-25, 9:12

Forum Jump:


Users browsing this thread: 1 Guest(s)