Author Topic: setRotationPivot translates my object  (Read 757 times)

Offline arash

  • byte
  • *
  • Posts: 8
    • View Profile
setRotationPivot translates my object
« on: September 18, 2013, 02:40:44 pm »
Hi,

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

When I do the following

Code: [Select]
xConeRight.setRotationPivot(new SimpleVector(15, 15, ,15));
it is the same as if I was doing

Code: [Select]
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: setRotationPivot translates my object
« Reply #1 on: September 19, 2013, 07:23:42 am »
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... ???

Offline arash

  • byte
  • *
  • Posts: 8
    • View Profile
Re: setRotationPivot translates my object
« Reply #2 on: September 19, 2013, 01:12:46 pm »
Thanks for the quick response. but I really get my objects translated with the setRotationPivot method.

This code

Code: [Select]
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
Code: [Select]
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]
« Last Edit: September 19, 2013, 01:17:54 pm by arash »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11745
    • View Profile
    • http://www.jpct.net
Re: setRotationPivot translates my object
« Reply #3 on: September 19, 2013, 01:21:10 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.

Offline arash

  • byte
  • *
  • Posts: 8
    • View Profile
Re: setRotationPivot translates my object
« Reply #4 on: September 19, 2013, 02:05:32 pm »
Ahaa... got it.  ;D
Thanks man.