# Relative coordinates - Absolute coordinates?

This topic is 3772 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi! Something that should be "really easy" to do is slipping my mind... How do I transform a bunch of rotations and transforms into absolute coordinates and an absolute matrix?
//pseudo:
obj.pos(10,0,0);
obj.rot(1,0,0,90);
obj.child1.pos(10,0,0);  //child1 gets translated with parents matrix.
obj.child1.rot(1,0,90);  //child1's children would get translated by child1.matrix

obj.child1.getAbsoluteCoords();


What I've got so far is the following, but only the first child (root->child) is rotated correctly, root->child->child is rotated globaly (or something...).
            rot = parentRot * localRot;
Vector3<scalar> direction = rot * localPos;
globalPos = position + direction;
globalRot = rot;

for (list<sceneNode>::iterator child=children.begin(); child != children.end(); ++child)
(*child)->setGlobalPos(globalPos,globalRot);


For the moment I'm using quaternions and vectors, and OpenGL for rendering, if that matters. :) Would be nice if any of you fine people could help a laddie in distress. :P /Robert

##### Share on other sites
I assume you use the typical order (given for column vectors, since you spoke of OpenGL)
T * R
where T denotes a translation and R a rotation. Then the composited transformation matrix of a local frame 1 is just
M12 := T1 * R1
what relates local co-ordinates to the superior frame 2. The superior frame 2 itself is related to its own superior frame 3
M23 := T2 * R2
Then frame 1 is related to frame 3 by
M13 := M23 * M12

You may have a look at this thread, too. It shows an efficient mechanism how to deal with the issue.

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5
A4L
12

• 11
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633723
• Total Posts
3013541
×