In this worksheet, the user will experiment with Linear Transformations and Computer Graphics
John Travis
Mississippi College
Matrix Transformations
If T:$R^n \rightarrow R^m$ is a Linear Transformations, then $T(x)=Ax$, for some unique matrix $A$. Therefore, one can completely describe a linear transformation using a matrix. For computer graphics, all screen images consist of a discrete collection of points. A linear transformation on these points will cause the image to be distorted in some manner. Some interesting transformations discussed in Linear Algebra include reflections, expansion and contraction, shears, projections and combinations of these. In the experiment below, we will start with the blue "home plate" and see what happens when an input transformation acts upon that image. You can enter whatever you want for the matrix $A$ but you might want to utilize one (or a multiplicative product) of the standard transformations from the text. (Also, if you care to notice the coding, we only map corner points instead of all points since linear transformations map lines to lines.)
Click to the left again to hide and once more to show the dynamic interactive window |
Traceback (click to the left of this block for traceback) ... SyntaxError: invalid syntax Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_7.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("KSAgIAojICAgICAgICBFbmRCb3ggKz0gbGluZTJkKFtjMSxjMl0sdGhpY2tuZXNzPTUsIHJnYmNvbG9yPSgwLjUsMSwwLjUpKSAgIAogICAgICAgICAgIAogICAgc2hvdyhTdGFydEJveCtFbmRCb3gsYXNwZWN0X3JhdGlvPVRydWUp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module> File "/tmp/tmpUDT0A7/___code___.py", line 2 ) ^ SyntaxError: invalid syntax |
Now, experiment with some transformation matrices that you choose. You can combine transformation but multiplying the simple transformations already discussed above.
Assignment:
|
Or perhaps flip over x-axis, then rotate 60°, then skew left, and then finally expand horizontally.
|
Click to the left again to hide and once more to show the dynamic interactive window |
Let's do the above but with a bunch of points!
Notice what happens to the ideas of contraction, expansion, left and right when the scalar is less than 1
Click to the left again to hide and once more to show the dynamic interactive window |
For the images above, only the corners were transformed since lines are mapped to lines under linear transformations. This saves time rather than transforming each pixel dot for all the lines in the square. For more general images, each pixel must be submitted to the transformation. For the experiment below, we will start with a general image and apply the same inputs as above.
(The hope is that the student would be able to upload an image on their own to use here.)
Below is under construction. Suggestions are welcome!
Can you figure out how to take this image in Sage and apply the various transformations...
Click to the left again to hide and once more to show the dynamic interactive window |
|
Click to the left again to hide and once more to show the dynamic interactive window |
|
[(1, 0), (-2, 1)] [(1, 0), (-2, 1)] |
|