Page 1 of 1

Rotate an object from API

Posted: 09 Apr 2024, 18:06
by mohammadhosseink
Hello,

I want to rotate a shape (a mesh) from API (Zmq), just like the option provided by the Rotation tab in the Orientation dialogue in Coppeliasim. So I want to simply rotate the object around the z-axis for some value ( z-axis of world frame, but not around the world as the center ).

Cheers,

Re: Rotate an object from API

Posted: 10 Apr 2024, 08:56
by fferri

Code: Select all

eulerAngles = sim.getObjectOrientation(shapeHandle, sim.handle_world)
eulerAngles[3] = eulerAngles[3] + amount
sim.setObjectOrientation(shapeHandle, eulerAngles, sim.handle_world)
Notes:
  • sim.handle_world is the default, so it is not required to specify it;
  • objects rotate around their origin. Arbitrary rotation centers can be obtained by temporarily reparenting to another object, e.g. a temporary dummy placed in the desired location of the rotation center, or the object reference frame can be changed (see the "relocate shape reference frame" family of functions).

Re: Rotate an object from API

Posted: 11 Apr 2024, 11:26
by mohammadhosseink
Thank you. I am familiar with sim.SetObjectOrientation functionality. However, the alpha, beta, omega values that you wish to pass to the function do not work as you defined it, since the object's frame is oriented relative to the world frame, and it's not a general answer to this problem. However, I changed my scene in order to make such a definition work.

Re: Rotate an object from API

Posted: 11 Apr 2024, 13:37
by fferri
Then you want to specify the frame relative to something else than sim.handle_world.
Simply change that parameter when calling sim.setObjectOrientation

Re: Rotate an object from API

Posted: 12 Apr 2024, 13:41
by coppelia
Have also a look at sim.rotateAroundAxis

Cheers

Re: Rotate an object from API

Posted: 21 Apr 2024, 09:18
by mohammadhosseink
fferri wrote: 11 Apr 2024, 13:37 Then you want to specify the frame relative to something else than sim.handle_world.
Simply change that parameter when calling sim.setObjectOrientation
Thanks fferri! I didn't know it was possible to set orientation relative to the object's handle itself.