PDA

查看完整版本 : R2-D2, Rotations and Dilations in Two Dimensions - Cleve Moler on Mathematics and Computing


poster
2023-03-04, 14:51
R2_D2 is is the name I've given a new MATLAB program that provides animations of 2-by-2 rotation and dilation matrices. I admit I chose "dilations" so the acronym would be memorable, but otherwise the code has little to do with the famous Star Wars droid.

Contents


House (https://www.labfans.com/bbs/#44861ff7-11fc-4399-ad23-d58213ec0d26)
Hand (https://www.labfans.com/bbs/#23ac6c7d-9deb-4368-af3a-b72341fd82e0)
Rotation (https://www.labfans.com/bbs/#a87fd4bd-4298-4c71-a3c2-a9f90fa02fbe)
Dilation (https://www.labfans.com/bbs/#4b0e42eb-235d-4dc6-8a7e-5cfafe76b486)
Both (https://www.labfans.com/bbs/#3bd73ac8-4279-4bb6-b08e-9f866181f581)
R2_D2 (https://www.labfans.com/bbs/#384f6c01-d1f5-456f-a0d0-b31ba5b772b2)
Further Reading (https://www.labfans.com/bbs/#f6931ffe-5f30-439a-97cb-2e04cab0aeaf)

House

This outline of a house is featured in Experiments with MATLAB (https://www.mathworks.com/moler/exm/chapters.html). The data are the 11 blue dots. The coordinates of each dot form a 2-by-1 vector; the 2-by-2 rotation and dilation matrices multiply each of these vectors separately. (The lines between the dots complete the picture and are not involved in any computation.)

http://blogs.mathworks.com/cleve/files/house.gif

The house also appears in several editions of Gil Strang's textbooks. The cover of the third edition of Strang's Introduction to Linear Algebra (https://www.amazon.com/Introduction-Linear-Algebra-Gilbert-Strang/dp/0961408898) features nine houses on a quilt made by Gil's friend Chris Curtis.

http://blogs.mathworks.com/cleve/files/quilt.png

Hand

This outline of a hand, which I made from measurements of my own hand, is also used in Experiments with MATLAB (https://www.mathworks.com/moler/exm/chapters.html). There are 37 points, so Hand is a 2-by-37 matrix.

http://blogs.mathworks.com/cleve/files/hand.gif

Rotation

Multiplication by this matrix produces a two-dimensional rotation by an angle theta.

$$ R = \left( \begin{array}{rr} \cos{\theta} & \sin{\theta} \\ - \sin{\theta} & \cos{\theta} \end{array} \right) $$

R is displayed in the first panel. If the house is not rotating in your browser, try this link: https://blogs.mathworks.com/cleve/files/house_rotate.gif

http://blogs.mathworks.com/cleve/files/house_rotate.gif

Dilation

Dilation is the process of making objects larger or smaller. Multiplication by this diagonal matrix produces a dilation by a factor sigma.

$$ S = \left( \begin{array}{rr} \sigma & 0 \\ 0 & \sigma \end{array} \right) $$

S is displayed in the second panel. The animation is also available at: https://blogs.mathworks.com/cleve/files/hand_dilate.gif

http://blogs.mathworks.com/cleve/files/hand_dilate.gif

Both

Here rotation and dilation are combined. The product of the rotation and dilation matrices drives the action. If you are missing all the action, try: https://blogs.mathworks.com/cleve/files/hand_both.gif

http://blogs.mathworks.com/cleve/files/hand_both.gif

R2_D2

When you run R2_D2 on your own computer, you can drive the rotations and dilations yourself. Mousing outside of the object creates rotation and mousing inside produces dilation.

The R2_D2 program is available from https://blogs.mathworks.com/cleve/files/R2_D2_4.m.

Further Reading

If you are not familiar with matrices, or just want a quick refresher, check out the Matrices (https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/moler/exm/chapters/matrices.pdf) chapter of Experiments with MATLAB (https://www.mathworks.com/moler/exm/chapters.html). Exercise 4.14 is particularly handy.


Get the MATLAB code (requires JavaScript) (javascript:grabCode_0fd9ed7550fd4ba3911f9d86fad47cd5())

Published with MATLAB® R2023a





More... (https://blogs.mathworks.com/cleve/2023/03/03/r2-d2-rotations-and-dilations-in-two-dimensions/?s_tid=feedtopost)