MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB技术文章 (https://www.labfans.com/bbs/forumdisplay.php?f=25)
-   -   R2-D2, Rotations and Dilations in Two Dimensions - Cleve Moler on Mathematics and Computing (https://www.labfans.com/bbs/showthread.php?t=27378)

poster 2023-03-04 14:51

R2-D2, Rotations and Dilations in Two Dimensions - Cleve Moler on Mathematics and Computing
 
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.

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

This outline of a house is featured in [URL="https://www.mathworks.com/moler/exm/chapters.html"][I]Experiments with MATLAB[/I][/URL]. 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.)

[IMG]http://blogs.mathworks.com/cleve/files/house.gif[/IMG]

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

[IMG]http://blogs.mathworks.com/cleve/files/quilt.png[/IMG]

[B]Hand[/B]

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

[IMG]http://blogs.mathworks.com/cleve/files/hand.gif[/IMG]

[B]Rotation[/B]

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: [URL]https://blogs.mathworks.com/cleve/files/house_rotate.gif[/URL]

[IMG]http://blogs.mathworks.com/cleve/files/house_rotate.gif[/IMG]

[B]Dilation[/B]

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: [URL]https://blogs.mathworks.com/cleve/files/hand_dilate.gif[/URL]

[IMG]http://blogs.mathworks.com/cleve/files/hand_dilate.gif[/IMG]

[B]Both[/B]

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: [URL]https://blogs.mathworks.com/cleve/files/hand_both.gif[/URL]

[IMG]http://blogs.mathworks.com/cleve/files/hand_both.gif[/IMG]

[B]R2_D2[/B]

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 [URL]https://blogs.mathworks.com/cleve/files/R2_D2_4.m[/URL].

[B]Further Reading[/B]

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

[RIGHT][COLOR=gray][I]
[URL="javascript:grabCode_0fd9ed7550fd4ba3911f9d86fad47cd5()"][I]Get the MATLAB code (requires JavaScript)[/I][/URL]

Published with MATLAB® R2023a
[/I][/COLOR][/RIGHT]




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


所有时间均为北京时间。现在的时间是 05:13

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.