#799 – How Transforms Are Combined

Because all transforms in WPF use homogeneous coordinates, combining transforms is accomplished simply by multiplying one or more 3 x 3 matrices together.

For example, suppose that we want to combine a rotation and a translation transform:

                <TransformGroup>
                    <RotateTransform Angle="30"/>
                    <TranslateTransform X="5.0" Y="10.0"/>
                </TransformGroup>

Recall that the 3 x 3 transformation matrix for rotation looks like:
799-001

And recall that the 3 x 3 transformation matrix for translation looks like:

799-002

To combine these two transforms together, we multiply the matrices, but in the opposite order from how they are listed:

799-005

For the example above, that works out to:

799-006

Multiplying any point by this final matrix will result in the point first being rotated and then translated.

In WPF, all of this works automatically behind the scenes.  You just specify in XAML the transforms that you want applied to your user interface elements and WPF calculates and stores the proper transformation matrix.

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

One Response to #799 – How Transforms Are Combined

  1. Pingback: Dew Drop – April 16, 2013 (#1,528) | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: