|
|
|
< shapes |
Affine Transformations |
system variables > |
|
|
A transformation whereby parallel lines remain parallel is called 'affine'. Examples include rotation, flipping a shape over, movement to a different location, uniform shrinking or expanding, skewing etc. (the trigonometric functions are examples of non-affine transformations). Some of these transformations are impossible to achieve using the simple arithmetic functions, and where they are possible they may require a number of operations to achieve the required result. What is needed is a simple one step procedure which will perform any desired affine transformation. Naturally Tymless provides such a procedure! It turns out that any affine transformation can be defined by a set of six numbers, or three complex numbers. Tymless allows you to store these numbers in an 'affine transformation' object, which is treated as a special kind of shape having three corners. // an affine transformation of a pythagorean triangle The affine transformation object is created using the affine function, which either takes a list of three locations, or a list of six numbers. The transform function.applies the affine transformation to the shape. How does it work? For each location (i.e. corner) in the shape, a new location is calculated where: x new = x 1
+ (x 2 * x old)
+ (x 3 * y old) Affine transformations take a bit of getting used to, but they have some interesting applications. And Tymless makes them easy to experiment with. |
|
< shapes |
system variables > |