Notifications
Clear all
[Closed] Position and Rotation | Local space
Jun 22, 2011 12:10 am
Im trying to place the teapot which is at a [0,0,50] world position, to a planes local [0,0,50] space.Which the positioning part of it works. The rotation is wrong though. Its opposite.
In this example the teapot goes to the correct position, but the rotation is opposite of what it should be.
(
undo on (
clearListener()
newMatrix = $Teapot01.transform * $Plane01.transform -- Calculate offset between objects
$Teapot01.position = newMatrix.position
in coordsys (transmatrix $Teapot01.transform.pos) $Teapot01.rotation = quatToEuler newMatrix.rotation
)
)
this is the sloppy solution
(
undo on (
clearListener()
newMatrix = $Teapot01.transform * $Plane01.transform -- Calculate offset between objects
$Teapot01.position = newMatrix.position
newRotation = quatToEuler newMatrix.rotation
newRotation.x *= -1;
newRotation.y *= -1;
newRotation.z *= -1;
in coordsys $Teapot01.transform $Teapot01.rotation = newRotation
)
)
attached is the test scene.
3 Replies
Jun 22, 2011 12:10 am
tm = $plane01.transform
$teapot.transform = matrix3 tm.row1 tm.row2 tm.row3 (transMatrix [0,0,50] * tm).row4
Jun 22, 2011 12:10 am
similar:
$Teapot001.transform = (transMatrix [0,0,100]) * $Plane001.transform
Jun 22, 2011 12:10 am
the same as:
$Teapot01.transform = preTranslate $Plane01.transform [0,0,50]