Home / Xpresso / Xpresso Anonymous / Coordinates


Global and local coordinates




Global coordinates are the coordinates of an object in regard to world zero, whereas local coordinates are based on the parent object. If the object has no parent both coordinates are identical. This is valid for Position, Scale and Rotation. All of them can either be local or global. The values you see in the coordinates section of the Attribute Manager are always local. Only the Coordinates Manager can be set to show global values. When you are using object nodes both sets are available. Only Global Scale is not available since it is practicaly never used.
The basis for all those coordinates is the matrix. It's a 4x4 Matrix which is reduced to 3x4 for ease of use.
A matrix consists of 4 vectors with 3 values each. V0 holds the positon(offset) while V1-V3 store the rotation and scale. V1-V3 are not directly usable. Anyone who is interested in more details on how matrices work should have a look at Mikael Sternes chapter on matrices that can be found in the C.O.F.F.E.E. SDK Documentation on plugincafe
If we need access to these vectors we can use special adapter nodes for it.
Why the hassle to use something as complexe as a matrix in the first place? Well, it might be complexe but it makes things easier. Matrices hold all the information we need in one compact package and they allow for some tricks that realy make life easier.
One example for this is known to you as the Target Expression. How would you start recreating this expression? Some of you who know trigonometry might start with sinuses and cosinuses but the easiest way is via vectors and matrices.
The main thing we need is the difference vector between the object that shall be adjusted and it's target. We will need the global coordinates for this since the Expression hast to work independent from the hierarchy of the objects.
By substracting one vector from the other we get a difference vector which you can imagine as an arrow pointing from one object to the other.
This difference vector is all we need, except that we currently can't use it to rotate our object accordingly. What we will need is a new matrix based on this vector. For this operation there is a readymade node in Xpresso called "Vector 2 Matrix". It creates a matrix which when fed in the Global Matrix input port of an object will allign it according to the difference vector, but a major thing is missing. The difference vector contains no information on its start position (remember thats V0 in a matrix). We can correct this by splitting the matrix in it's components and feeding in the original position of the object.
The complete setup looks like this and is available as a scene here.

To make things a bit more interesting we will have a look at a bit different solution. The basis (Difference Vector) is the same but instead of directly assigning the matrix we want to use a rotation only. For this we have the "Matrix 2 HPB" node. To access the combined rotational vector just click on the red rectangle in the top right corner of the node and select it. Now feed this rotation in the global rotation of the object. You can find this scene here.
Both setups will give you the same result.
Back Xpresso Anonymous