SetOrigin, SetPosition in a vtk3DProp

Hi,

I’m new to VTK and I’m struggling to understand what setOrigin and setPosition mean in vtk3DProp. I’m trying to display multiple cubes ( with specific x, y, z lengths and x, y, z co-ordinates with labels) using vtkAnnotatedCubeActor. Unlike vtkCubeSource, I cannot specify a center or x, y, z lengths for vtkAnnotatedCubeActor. As I understand I can use SetOrigin, SetPosition and SetScale to achieve the result I want but I’m failing to understand how these map to each other. Can anybody explain these to me ? Any help is greatly appreciated !

Thank you in advance,
Ujjwala

Hello,

My two cents: setOrigin() sets the object’s origin with respect to the world whose origin is 0,0,0. setPosition() sets the postion of the actor with respect to its origin. setOrigin() is very useful if your model has local coordinate systems.

For example, suppose you’re modeling the Solar System. You place the Sun actor at origin=0,0,0 and position=0,0,0 so it occupies the center of the Solar System. Then you place the Earth actor 150 million km away from the Sun, but you make Earth’s origin at the Sun because the former orbits the latter: origin=0,0,0 and position=150000000,0,0. Then you place the Moon actor with respect to the Earth, not the Sun and 400,000km away from the Earth: origin=150000000,0,0 and position=300000,0,0. This way, you don’t need to make complicated computations to make the Moon orbit the Earth while it orbits the Sun with only global heliocentric coordinates.

setScale() will scale the XYZ values of the actor with respect to its origin. In the example above, if you apply a 2x,2x,2x scale to the Moon actor, it will double in size and end up twice further away from the Earth.

I hope this helps casting some light on the subject.

take care,

Paulo

Thank you so much Paulo ! Your detailed is much appreciated and definitely helps a ton !

this is a great example, but I am not sure the logic is completely correct.

  1. as far as I tested most actor created by vtk has origin (0,0,0), which I think is local as when you move the actor the origin does not change.

  2. take the moon for example, if you set moon’s origin to the earth in a world coordinate, as the earth moves, you have to update the origin all the time, which i think is not how it is done in vtk.js

vtk.js documentation is very vague about it and I think it should be fixed.

setOrigin

Set the origin of the Prop3D. This is the point about which all rotations take place.

setPosition

Set the origin of the Prop3D. This is the point about which all rotations take place.

I think the difference is that setOrigin uses local coordinate and setPosition uses world coordinate. That’s my understanding as I tested it. Someone could confirm or correct it.

Yes. Surely, you have to apply a rotation (a transform) to the Moon’s local coordinate system (origin at center of the Earth). My simplistic example was to illustrate the role of each function.