[Closed] Scripting rotation of objects in maxscript
Hi Guys,
I’m having some trouble setting the rotation of a an object in maxscript.
I need to set the orientation of one object to match that of another (point). I can set the position, but the rotation appears to use some kind of algorithm that is past my head at this point.
Cheers
$targetObj.transform.rotation = $sourceObj.transform.rotation
Something like that?
-Johan
Hello,
could you specify more “set the orientation of one object to match that of another (point)” – maybe I don’t get the problem…
This will make box01 rotation equal to box02 in world coordinates:
in coordsys world
(
$box01.rotation = $box02.rotation
)
I think you should also check Orientation_Constraint:
(
oc = Orientation_Constraint()
oc.appendTarget $box02 1.0 --set target node with weight 1.0
--with Orientation_Constraint you can add another objects with diffrent weights
$box01.rotation.controller = oc
)
jk
here´s my snippet:
tm = $SourceObj.transform
pos = $TargetObj.pos
new_TM = matrix3 tm.row1 tm.row2 tm.row3 pos
$TargetObj.transform = new_TM
You want just the rotation (vectors orientation),
so the key is to collect all them by going under matrix transform rows except the row4 (translation part).
not an algorithm itself, but vectors product math concept behind it. e.g:
A *(esc) B = |A| * |B| * cos(Theta)
–vectors that generates an escalar product
|A x(vec) B| = |A| x |B| x sin(Theta)
–vectors that generates another vector
http://reference.wolfram.com/mathematica/tutorial/VectorOperations.html
http://demonstrations.wolfram.com/CrossProductOfVectorsInTheYZPlane/
http://demonstrations.wolfram.com/CrossProductOfVectors/
http://demonstrations.wolfram.com/VectorRotationsIn3D/
http://demonstrations.wolfram.com/ComplexMultiplication/
hope it helps.