Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Issue with transformation matrices

6 views
Skip to first unread message

Alexander Adam

unread,
Apr 1, 2010, 4:32:20 AM4/1/10
to
Hi all,

I might be too dumb to solve this or I simply can't figure how to get
it right though the issue seems to be quite simple:

I've got a few objects with a simple, affine transformation matrix on
them, for example:

object1 -- identity matrix
+ object2 -- (3 0 0 3 400 400)
+ object3 -- (0.7 0.7 -0.7 0.7 0 0)
+ object4 -- (3 0 0 3 400 400)

Now, how it works is that each sub-object of another object inherits
the transformation matrix from it's parents and grand-parents
including it's own transformation. Now what I am trying to do is to
apply a new transformation matrix, for example a simple translation (1
0 0 1 200 200) to "object4". This works quite fine. However, because
of the nature of parent transformation inheritance, when trying to
apply the same translation transform to "object3", I'll actually get
wrong results, because of course instead of a translation of 200 200,
due the parent's scalation factors I actually end up the "object3"
having a translation of 600 600. Now what I thought was to multiply my
new translation transform with the inverse matrix of the parent (i.e.
"object2") which whould actually work for the translation factors but
of course multiplying with the inverse parent matrix in this case
results in "object3" to loose it's scalation factor of 3 3. Now what
to do? I am really stuck here so hoping that anyone can help in this
simple issue.

thanks a lot,
Alex

Dave Eberly

unread,
Apr 2, 2010, 4:04:00 PM4/2/10
to
"Alexander Adam" <con...@emiasys.com> wrote in message
news:bafaf1e7-4569-4bd9...@i25g2000yqm.googlegroups.com...

> I've got a few objects with a simple, affine transformation matrix on
> them, for example:
>
> object1 -- identity matrix
> + object2 -- (3 0 0 3 400 400)
> + object3 -- (0.7 0.7 -0.7 0.7 0 0)
> + object4 -- (3 0 0 3 400 400)
>
> Now, how it works is that each sub-object of another object inherits
> the transformation matrix from it's parents and grand-parents
> including it's own transformation. Now what I am trying to do is to
> apply a new transformation matrix, for example a simple translation (1
> 0 0 1 200 200) to "object4". This works quite fine. However, because
> of the nature of parent transformation inheritance, when trying to
> apply the same translation transform to "object3", I'll actually get
> wrong results, because of course instead of a translation of 200 200,
> due the parent's scalation factors I actually end up the "object3"
> having a translation of 600 600. Now what I thought was to multiply my
> new translation transform with the inverse matrix of the parent (i.e.
> "object2") which whould actually work for the translation factors but
> of course multiplying with the inverse parent matrix in this case
> results in "object3" to loose it's scalation factor of 3 3. Now what
> to do? I am really stuck here so hoping that anyone can help in this
> simple issue.

This is a standard example of hierarchical transformations. Each node of
the hierarchy has one parent, except for the root node which has no parents.
Each node can have an arbitrary number of child nodes. A node maintains two
transformations, a local transformation and a world transformation. The
entire hierarchy lives in the world coordinate system. The world
transformation represents how to transform the object from "model space" to
"world space". The term model space refers to the coordinate system in
which the model was built (such as a 3D model built in 3ds Max or Maya).
The local transformation for a node represents a transformation applied in
the parent's coordinate system. If you have a linear path in the hierarchy,
say, Root -> Node0 ->Node1, then
Root.WorldMatrix = Root.LocalMatrix
Node0.WorldMatrix = Root.WorldMatrix*Node0.LocalMatrix
Node1.WorldMatrix = Node0.WorldMatrix*Node1.LocalMatrix
The application of the matrix to a vector is from right-to-left. For
example, a vector in Node1's local coordinate system is transformed to world
coordinates by applying Node1.LocalMatrix first, Node0.WorldMatrix second.

Your second example indicates you are trying to translate object3 to a
*world* location of (200,200), but the problem is that you applied a
translation (200,200) in the *local* coordinates of the object. You need to
infer what object3's local transformation is based on what you want its
world transformation to be.

Write the transformation as you have, where the first four entries are for
the 2x2 matrix and the last two entries are the translational component.

// you know this matrix
object2.WorldMatrix = (a00,a01,a10,a11,b0,b1);

// you choose this matrix; for example, (d0,d1) = (200,200)
object3.WorldMatrix = (c00,c01,c10,c11,d0,d1);

// the matrix relationship
object3.WorldMatrix = object2.WorldMatrix*object3.LocalMatrix

// the answer
object3.LocalMatrix = Inverse(object2.WorldMatrix)*object3.WorldMatrix

But I believe this is what you proposed. The problem is that you have
chosen (d0,d1) of object3's world matrix, but you also have to choose the
other four entries. If you want its world matrix to scale the object, then
you would choose object3.WorldMatrix = (3,0,0,3,200,200). The conclusion is
that object2.WorldMatrix = (3,0,0,3,400,400), Inverse(object2.WorldMatrix) =
(1/3,0,0,1/3,-400/3,-400/3), and object3.LocalMatrix =
(1,0,0,1,-200/3,-200/3).

--
Dave Eberly
http://www.geometrictools.com


0 new messages