setRotationPivot translates my object

Started by arash, September 18, 2013, 02:40:44 PM

Previous topic - Next topic

arash

Hi,

I am having a very hard time understanding how setRotationPivot works on AE version

When I do the following

xConeRight.setRotationPivot(new SimpleVector(15, 15, ,15));

it is the same as if I was doing

xConeRight.translate(30, 0, 0);

and then when I call rotateX or rotateY the object actually rotates around point (15, 0 ,0 )

I appreciate any help.

EgonOlsen

setRotationPivot sets the point around which the object will be rotated in OBJECT space. It has nothing to do with translations in world space albeit it might be possible that a rotation around the origin followed by a translation will lead to the same result as a rotation only around some other pivot.
I'm not sure what you mean by your last sentence. A rotation around an axis can't rotate around a point... ???

arash

#2
Thanks for the quick response. but I really get my objects translated with the setRotationPivot method.

This code


xConeLeft = Primitives.getCone(90, 2);
xConeRight = Primitives.getCone(90, 2);
xConeRight.setAdditionalColor(new RGBColor(0, 0, 255));
xConeLeft.setAdditionalColor(new RGBColor(255, 0, 0));
xConeRight.rotateZ((float) -Math.PI/2);
xConeLeft.rotateZ((float) Math.PI/2);
xConeRight.strip();
xConeLeft.strip();
xConeRight.build();
xConeLeft.build();
world.addObject(xConeRight);
world.addObject(xConeLeft);

xConeRight.setRotationPivot(new SimpleVector(10, 10, 10));


results in this image:



and this code

xConeLeft = Primitives.getCone(90, 2);
xConeRight = Primitives.getCone(90, 2);
xConeRight.setAdditionalColor(new RGBColor(0, 0, 255));
xConeLeft.setAdditionalColor(new RGBColor(255, 0, 0));
xConeRight.rotateZ((float) -Math.PI/2);
xConeLeft.rotateZ((float) Math.PI/2);
xConeRight.strip();
xConeLeft.strip();
xConeRight.build();
xConeLeft.build();
world.addObject(xConeRight);
world.addObject(xConeLeft);

results in this image


however If I don't have xConeRight.rotateZ((float) -Math.PI/2);
then it all works fine.



[attachment deleted by admin]

EgonOlsen

Quote from: arash on September 19, 2013, 01:12:46 PM
but I really get my objects translated with the setRotationPivot method.
No, you don't. If you rotate something around a point in space that's far outside of the object itself, it will move in space. Maybe you are confused by the order...well, it doesn't matter. There's no difference between rotateZ(...);setRotationPivot(); and setRotationPivot();rotateZ(...);. Rotations will be executed at runtime and only the current rotation pivot counts. Rotations are cumulative, pivots are not.

arash