Skip to content

Simple Introduction to Matrix’s in Softimage

March 30, 2012

Hi Everyone,

I saw on Tuesday someone brought up the topic of matrices, and there where few comments about them so I thought I would get my first blog post done on the topic of Matrices, what are they, how are they helpfull in Softimage and most of all how do we use them.

What is a Matrix:

In simple terms a Matrix is a 2D array of numbers that represent some sort of information, in our case its the Global or Local Kinematics Property.

What most people assume is that a matrices are a very simple representation of Translation, Rotation and Scale and some other arb grouping or numbers in a list

[ rotX, rotY, rotZ, ??]
[ sclX, sclY, sclZ, ??]
[ tranX, tranY, tranZ, ??]
[ ??, ??, ??, ??]

This is infact incorrect, yes the values that are represented in an matricie are the Translation, Rotations and Scale values, but there represented in a much more complicated way and rotations are interacted with differently not just direct rotations along the X, Y,Z. In a Matrice you have your rotation and point from where you want to rotate or your relative space of rotation as one could think of it.

So a quick break down or the simple information a Matrice has:

Matrices are relative to one another, in other words if you multiple matricies together it will use the matricies multiplied as its relative to an arbitary point.

A matrix in Softimage looks like this:

 [ scale X , matriXinfo, matriXinfo, matriXinfo ]
 [ matriXinfo, scaleY, matriXinfo,matriXinfo ]
 [ matriXinfo, matriXinfo, scale Z, matriXinfo ]
 [ translate X, translateY, translate Z, matriXinfo ]

The basics of a Matrix in Softimage

Most Matrices outside of Softimage have the translation along the right hand side.

As you see above alot of the elements I have named matriXinfo, this is due to special equation one will perform on a matricie that will use these specific elements place holders, I will ge to that at a later stage. matrixInfo is not the correct mathematical term, its just a way I think of it in my head, Please feel free to correct me.

If you where to now create an ICE Tree now on a null and attach a Matrix to the global position of a null you would be able to see the different ways you can quickly interact with the null and move it and scale it.

Please note Scaling is relative to a arbitary point, so if you just have a simple matrix snad scale it will scale correctly if you have two Matrices multiplied together and scale the one you will see it will scale from the point of the other matrix. I will show you how to get around that later.

With Matrices you never add you always multiply.

Why Use Matrix’s:

Using a Matric is faster then doing all the other property process to worm your way down to your rotation, translation values, and is extremly fast when trying to compute children to parent combinations.

Interacting with Matrices

In Math 1* 1 = 1
In Math X * 1 = X
In Matrix X * [ 1,0,0,0]
              [ 0,1,0,0] = Matrix X
              [ 0,0,1,0]
              [ 0,0,0,1]

That is the basic building block for interaction with a Matrix for u.

Translation

To translate a Matrix all you have to do is multiply the matrix’s together and change the Translation X, Translation Y or Translation Z on the Matrix.

[ 1,0,0,0]              [ 1,0,0,0]            [ 1,0,0,0]
[ 0,1,0,0]              [ 0,1,0,0]            [ 0,1,0,0]
[ 0,0,1,0]       X      [ 0,0,1,0]       =    [ 0,0,1,0]
[ 0,0,0,1]              [ 0,2,0,1]            [ 0,2,0,1]

in the example above we added 2 to the Y-axis

Scaling

Note: Scaling is relative to an arbitery point or the origin

[ 1, 0, 0, 0]              [ 1, 0, 0, 0 ]            [ 1, 0, 0, 0 ]
[ 0, 2, 0, 0]              [ 0, 1, 0 ,0 ]            [ 0, 2, 0, 0 ]
[ 0, 0, 1, 0]       X      [ 0, 0, 1, 0 ]       =    [ 0, 0, 1, 0 ]
[ 0, 0, 0, 1]              [ 0, 2, 0, 1 ]            [ 0, 2, 0, 1 ]

The above scaling example you will think that you have scaled your object by 2 on the X axis at the objects origin, but infact you have scaled it by two from the objects origin.

To scale an Object around the objects center you have to input the objects center in an equation in specific places I mentioned earlier ‘MatrixInfo’

for the next example

Object Center or Arbitary point = 3,0,0

[ 1, 0, 0, 0 ]                               [ 1, 0, 0, 0 ]                 [ 1, 0, 0, 0 ]
[ 0, 2, 0, 0 ]                               [ 0, 1, 0, 0 ]                 [ 0, 2, 0, 0 ]
[ 0, 0, 1, 0 ]              X                [ 0, 0, 1, 0 ]        =        [ 0 ,0, 1, 0 ]
[ 3( 1 - 1), 0( 1 - 2), 0( 1 - 1), 1 ]       [ 0, 0, 0, 1 ]                 [ 0, 1, 0, 1 ]

It might look a bit hard to grasp but what I have done above, is taken Arbitary point’s X position and then multiplied it by the result of 1 – scale X and performed that on X, Y, Z

ArbitaryPointX( 1 – scaleX ) which can be writen as [ apX( 1 – sX ) , apY( 1 – sY ) apZ( 1 – sZ ) ]

An ICE tree showing how to setup a Scale Matrix

Rotation

The Z-Axis (Roll)

rotZ = The Angle of Rotation you wish to apply

[ cos( rotZ ),-sin( rotZ ),0,0 ]
[ sin( rotZ ), cos( rotZ ),0,0 ]
[ 0,0,1,0 ]
[ 0,0,0,1 ]

The X-Axis( Pitch)

rotX = The Angle of Rotation you wish to apply

[ 1, 0, 0, 0]
[0, cos( rotX ), -sin( rotX ) , 0 ]
[0, sin( rotX ) , cos( rotX ) , 0 ]
[0, 0, 0, 1]

The Y-Axis (YAW)

rotY = The Angle of Rotation you wish to apply

[ cos( rotY ) , 0, sin( rotY ) , 0 ]
[ 0, 1, 0, 0 ]
[ -sin( rotY ) , 0, cos( rotY ) , 0 ]
[ 0, 0, 0, 1 ]

*Note: If you multiply the 3 Axis before you multiply the translation onto the matrix it will rotate around the world center with an offset of the translation Matrix. If you Multipe the Tranlsation after the Rotations then the object will rotate around its own center and keep the translation position

How to setup an ICE Treeto rotate around the origin

Rotation around an axis ie Rotating around an arbitary point: When you rotate an object, you are always rotate around the world axis, so in order to rotate around a specific point in world space you have to offset the world axis which you will be rotating around. As you have seen above we always rotate one axis at a time, so we shift the world axis one at a time. To test if my rotations where correct I would set a 2 keys and nable ghosting to see how the object rotating rotates around my arbitary point.

NOTE: Busy working on the rotation around an arbitary point ICE tree and Python scripted operators which I will attach at a later Stage( hopefully this weekend)

Reflection or Mirroring

Mirror X

 [ -1,0,0,0]
 [ 0,1,0,0]
 [ 0,0,1,0]
 [ 0,0,0,1]

Mirror Y

 [ 1,0,0,0]
 [ 0,-1,0,0]
 [ 0,0,1,0]
 [ 0,0,0,1]

Mirror Z

 [ 1,0,0,0 ]
 [ 0,1,0,0 ]
 [ 0,0,-1,0]
 [ 0,0,0,1 ]

They can be combined in any way you like, depending on the axis you wish to mirror

Hope you found this helpful, let me know if anything I wrote was incorrect or you want me to explain or cover something else.

Cheers for now

Si

Advertisements

From → ICE, Math, Python, Softimage

One Comment
  1. This is great stuff thanks Simon. I’ve always been a bit shakey with dealing with rotations via a matrix. this is a fantastic resource

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: