Notifications
Clear all
[Closed] No Flip LookAt
Apr 19, 2018 2:09 pm
I’m looking for a mathematical formula that solves this two problem of LookAt:
1 – No flip at any angle.
2 – No flip with negative scale.
I found this useful tutorial that solves number one, but number two still remained.
with redraw off(animate off(undo on(
delete objects
Last = Root = point centermarker:off axistripod:on cross:off box:off wirecolor:green size:10
Objs = for i = 1 to 3 collect
(
Obj = teapot pos:[i*20,0,0] radius:5 wirecolor:(color 100 120 100)
Obj.parent = Root
Last = Obj
)
for i = 1 to Objs.count-1 do
(
RS = rotation_script()
RS.addnode "Parent" (if i == 1 then Root else Objs[i-1])
RS.addobject "ThisPosController" Objs[i].position.controller
RS.addobject "TargetPosController" Objs[i+1].position.controller
RS.script =
"
ParentTransform = Parent.transform
ThisPos = ThisPosController.value*inverse ParentTransform
TargetPos = TargetPosController.value*inverse ParentTransform
vector = TargetPos-ThisPos
Axis = normalize (cross vector [1,0,0])
Angle = acos (normalize vector).x
(quat Angle Axis)*ParentTransform.rotation
"
Objs[i].rotation.controller = RS
)
-- Problem
Root.scale.controller.value *= [-1,1,1]
)))
How we can change the formula to work with negative scale?