It’s easy to ignore the X output at the bottom of transform batteries in Grasshopper. What the hell are these things and why are they there? They don’t give us geometry or lists of numbers, and when hovering over the output, we can see that the data is called a transformation matrix. Whatever that means.
Transformation matrices can be confusing, but they are really handy for several reasons. A matrix lets a programmer clean up a series of compound linear transformations and place them into a consistent format. Because of this, matrices are widely used in computer modeling. This post will walk through how to use matrices to create quick and easy animations of complex affine transformations. And it may get a little involved, so we’re offering a user object to download at the end of this post if you want to skip to that.
Before we jump into the details, let’s talk about why we’re looking at this topic. Above is a video by Daniel Piker from 4 years ago. I remember being inspired by this short as it’s a great visualization of parametric modeling concepts. Creating animations such as these is not only eye catching, but also helps designers better understand the results of design revisions.
I1,I2,I3,In refer to the dimensions of the matrix (or number of rows and columns). Notice how it’s a matrix full of zeros with a 1 along the diagonal. Grasshopper uses 4×4 matrices, so we’ll have an identity matrix with four columns and four rows to start. By animating between this identity matrix and the final transformation matrix, we can create fluid animations for any affine transformation:
The image above shows the concept behind animating transformations, and the grasshopper file at the bottom of the page should provide much more helpful information regarding its setup (the above image is not actually how the definition is setup, but is just a visual showing the logic behind it).
The above video shows a torus animation and a panel animation from the Octahedron. Since a transformation matrix is compatible with all affine transformations, we’ve created a GH user object to animate through a transformation using the X output.
Now, with the current user object, animating these transformations will in some cases result in distorted objects during animation. Basic operations like scale and translate work with linear coefficients on transformation matrices. However, a rotation matrix for example uses trigonometric functions, and since the slider is a linear animation, the geometry will certainly be distorted when animating. The final rotation (or last frame of your animation) will be correct, but the geometry will distort during the animation. As an example, the matrix below shows a rotation transformation matrix about a unit vector (l,m,n):Just something to keep in mind while animating. Regardless, this technique will help with transformations which are more difficult to animate, and should remain consistent with GH path structures in your definition.LMNts_Transformer (440)
Disclaimer: the author does not guarantee that these parametric models are bug-free or that they will solve all of your problems. If you find bugs or have suggestions for improvements, please let us know.