Sign in to follow this  

Find a point equivalent in a different space

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having a bit of trouble in finding a point that is in one space, in another space. So, just say I have point A, which is in world space. Then the object at point A needs to interact with an object in another space, and it would be much easier to put that object in the equivalent of it's current point, in the other space. So, basically I want the location of the object to stay the same, but it's position will be different because it will now be measured in reference to another object (space). Does that make sense?

Share this post


Link to post
Share on other sites
It's really easy actually :) Let's say you describe your space with 3 axes x, y, z and an origin o. You put the 3 axes into the rows of a 3x3 matrix, so 1st row is the x-axis, 2nd row is the y-axis and 3rd row is the z-axis. Let's say we have 3 spaces. Space PARENT, space CHILD1 and space CHILD2. Each has its 3x3 matrix and origin. CHILD1's and CHILD2's axes and origin are measured in reference to PARENT.

1)To move a point from a child to the parent:
Multiply the point with the child's matrix and add child's origin to the result.

2)To move a point from a parent to a child:
Multiply the point (x, y, z vector) with the INVERSE of the child's matrix, and subtract from the result the child's origin after you've multiplied the origin with the inverse of child's matrix.

3)To move a point between spaces that belong to the same parent-space, move first to parent and then to the other child.

Notes: if your axes are orthogonal to each other, the inverse of the matrix is its transpose, so you can save some calculations. Also, if you want to move a vector which only represents a direction and not a point(e.g. a force vector or the axes of another reference frame), just don't do anything with the origin of the spaces.
Sry for my spelling/english/any logic errors but i really am in a hurry (last minute studying for exam in 4 hrs :P:P)

PS: most ppl (and gfx apis) seem to pack the axes/origin in 4x4 matrices, someone else might want to post about that method.

EDIT: Transformations using 4x4 matrices

[Edited by - D_Tr on September 20, 2007 6:42:36 AM]

Share this post


Link to post
Share on other sites
A local co-ordinate frame is related to the world by a series of transformations. The series can be build of the transition from the inner local frame to an outer local frame to an outer local frame ... to the world:
MG := ML1 * ML2 * ... * MLn

Each transition itself is usually a concatenation of translation, rotation, and perhaps scaling. The usual order is (if written down for column vectors)
ML := TL * RL * SL
what means that 1st a mesh is scaled, then rotated, and then translated. Of course, other definitions are also possible (see e.g. VRML where the scaling and rotation may have own origins), but the rough order is the one given above.

Now, a vector given in a local frame L is transformed to the world by (still using column vectors)
vG := MG * vL

The other way, namely transforming from world to local frame L, is then obviously
vL := MG-1 * vG

With the common definition of a transformation, the inverse is given by
M-1 = S-1 * R-1 * T-1
so that, if one really wants to apply the parts one-by-one, one 1st has to translate it, and then has to rotate it (and then to scale it, if necessary).

If a point in one local frame L1 should be transformed into another local frame L2 then a common matrix
M12 := MG2-1 * MG1
can be build.

[If you're using row vectors then the order of any and all multiplications above is to be reversed, of course.]

EDIT: In fact, changing the co-ordinate frame doesn't change the position of a point. It only changes its reference and hence gives other co-ordinates since co-ordinates are measured with a frame as reference.

[Edited by - haegarr on September 19, 2007 4:21:25 AM]

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this