[Closed] ————-Rotate an object beased on another object position with no pivot change
Hi
Hope the title is clear and considering my beginner level of scripting here it is my try :
--our scene object
A = Circle name:"center of rotation" radius:10 wirecolor:green ; B= teapot name:"Rotating object" radius:15 pos:[100,0,0] wirecolor:yellow showtrajectory:on
---store initial transform
myPose = #(A.transform, B.transform)
rot = [0,0,1]
-----Just to show the result i animate the teapot
animate on for i = 0 to 100 by 10 do
(
at time i
(
newMatrix = ((eulerangles rot.x rot.y (rot.z * i)) as matrix3) * (transmatrix A.pos)
RTM = (myPose[2] * inverse myPose[1])
B.transform = RTM * newMatrix
)
)
Now lets change the position of the circle as the center of teapot rotation and repeat the code
A .pos = [-350,50,0]
myPose = #(A.transform, B.transform)
rot = [0,0,1]
animate on for i = 0 to 100 by 10 do
(
at time i
(
newMatrix = ((eulerangles rot.x rot.y (rot.z * i)) as matrix3) * (transmatrix A.pos)
RTM = (myPose[2] * inverse myPose[1])
B.transform = RTM * newMatrix
)
)
I hope there will be better and quicker way or any suggestion is so appreciated
Thanks in advance
you question is not clear enough… especially after looking into your code.
do you want to get a code how to rotate a node’s object only? (similar to “Affect Object Only”)
Denis thanks for your participation
Actually NO
I like to rotate an object around a position point 3 value ( this position will be animate able ) but i don’t want to change the pivot of the rotating object
Maybe because of my bad English or not using a proper Word it look so confusing.
I like to rotate an object (Target) based on another object’s(Source) position or coordsys or … .
The very first and quickest way is (Change the parent ) i mean link the Target to the source object then we can rotate target based on the position of Source object
Second one is to change the pivot of the Target to the position of source’s object then animate or rotate the Target based on the position of Source object
The third is link constrain .
Now my question is . Is there any other way? because i don’t want change the pivot or change the parent
I hope this make it better
the confusing part of your original question was “rotate but not change a pivot”…
you are simply talking about “rotate an object about another center or pivot position”
so here is it:
delete objects
t = point name:"target" pos:[0,0,0]
s = dummy name:"source" pos:[20,0,0]
in coordsys t about t rotate s (eulerangles 0 0 45)
/***** here is as you re-parent a source
s.transform = s.transform * inverse t.transform * (rotatezmatrix 45) * t.transform
*/
advanced code of the above is:
s.transform *= xformmat (rotatezmatrix 45) (inverse t.transform)
Yes . First one was exactly what i was looking for
Thank you very much denis for your participation and patience
Thank for both code