I am working with matrix math for parent / child transformations. I have to modify existing calculations to keep child scale constant while also keeping child position relative to its parent.

Here's some info about what I am given:


Appends two matrices. AB = A * B

a - The local (child) matrix.

b - The world (parent) matrix.


A matrix has of the following properties:

a - x scale

b - y skew

c - x skew

d - y scale

tx - x translation

ty - y translation

Working Calculations

This is the calculation that scales the child correctly based on parent resize:

a.a = (a.a * b.a) + (a.b * b.c)

This transfroms the child's x position correctly when the parent's x position changes:

a.tx = (a.tx * b.a) + b.tx

My goal

I want to keep the child's size constant, while still keeping it positioned based on the parent. When I try to change the transformation equation (a.tx), I get undesired results. I will post them below.

(To keep the child's scale the same I just set a.a = a.a)

This is the original parent/child setup. The parent is black, the children are all white

This is what I don't want. Here we keep the children at a constant scale, but when we shrink the parent, the children are offset from their original values

What is the correct equation to set a.tx to? I have tried a.tx = (a.tx + b.tx), but what didn't work either.



You must log in to answer this question.

Browse other questions tagged .