If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

4. Functions

Snowman rigging involves scale, rotate, and translate deformers using functions. Functions perform operations on inputs like coordinates and transformation magnitudes. Different equations define scaling, rotation, and translation. Deformers transform vertices in shapes, and functions run multiple times for each vertex. Click here to review functions. Click here to review geometric transformations.

Want to join the conversation?

Video transcript

- Alright, you finally have a snowman to start working with. Now we can get to the real guts of the rigging software. We need to define our scale, rotate, and translate deformers. To allow you to move your shapes around. And this is where functions come into play. Remember, functions package a series of operations or procedures we'll use many times. Functions are set input which they perform a set of operations on. Now, to build any deformer, we'll need a function which intercepts two inputs. First they must intercept a pair of coordinates which is the vertex in our shape. And lay a set of value which is a magnitude of transformation you want to apply. For example, the translate x to full might intercept a coordinate 2,2. And for the 2nd input would provide a value of say five. And so this translate x function, the math we'll do is quite simple. Hey that's five to the x coordinate which updates it to 7,2 and that's the process for transforming each vertex into shape. Of course, a shapes contain many vertices. For example, a hat has eight. That means its function is run eight times. Once for each vertex. Order of the deformer functions transform vertices using equations. And the transformation depends on the types of equations used in your functions. The equations used for scaling, rotate, and translation are all different from each other. We cover these equations in detail in our sets and staging lesson. In the next code review, we'll give you an example of writing a translation function and then in the exercise, we'll allow you to write free deformer functions on your own. Alright, I'm out of here. (chuckling)