2D-Graphics

We create the 2D graphic images described in Lay's textbook examples 2.7.1 through 2.7.6.

From In[308]:=

[Graphics:HTMLFiles/2_2d_graphics_1.gif]

Lay Example 2.7.1
The Letter "N"

Data points and adjacency matrix

In[1]:=

<<LinearAlgebra`MatrixManipulation`

In[2]:=

xs = {0, .5, .5, 6, 6, 5.5, 5.5, 0} ;

ys = {0, 0, 6.42, 0, 8, 8, 1.58, 8} ; 

data = {xs, ys} ;

%//MatrixForm

adj = ({{0, 1, 0, 0, 0, 0, 0, 1}, {0, 0, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 0}, {0, 0, ... 0, 0, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0, 0}}) ;

Out[5]//MatrixForm=

( {{0, 0.5, 0.5, 6, 6, 5.5, 5.5, 0}, {0, 0, 6.42, 0, 8, 8, 1.58, 8}} )

RenderData

The procedure RenderData takes an adjacency matrix and a list of points and plots the associated figure in a small screen.

RenderData is from the file "Case2.nb" available in the Case Studies section of the web site supporting Lay's textbook "Linear Algebra, Third Edition."
It is modified slightly to accomodate the data of these examples.

In[7]:=

n = 8 ;

viewWindow = {{-1, 10}, {-1, 10}} ; 

RenderData[adjacency_, data_, opts___] := (ptlist = {} ; For[i = 1, i≤n, i ++, ... tlist[[i]]]]] ; Show[Graphics[g, opts], PlotRange->viewWindow, AspectRatio1])

In[10]:=

img1 = RenderData[adj, data, DefaultColorRed] ;

[Graphics:HTMLFiles/2_2d_graphics_13.gif]

Lay Example 2.7.2
Sheared "N"

In[11]:=

shear = ( {{1, .25}, {0, 1}} ) ; 

shearData = shear . data ;

%//MatrixForm

Out[13]//MatrixForm=

( {{0., 0.5, 2.105, 6., 8., 7.5, 5.895, 2.}, {0., 0., 6.42, 0., 8., 8., 1.58, 8.}} )

In[14]:=

img2 = RenderData[adj, shearData, DefaultColorIndigo] ;

[Graphics:HTMLFiles/2_2d_graphics_19.gif]

Lay Example 2.7.3
Scaled Sheared "N"

In[15]:=

shear = ( {{1, .25}, {0, 1}} ) ;

scale = ( {{.75, 0}, {0, 1}} ) ; 

scaledShearData = scale . shear . data ;

%//MatrixForm

Out[18]//MatrixForm=

( {{0., 0.375, 1.57875, 4.5, 6., 5.625, 4.42125, 1.5}, {0., 0., 6.42, 0., 8., 8., 1.58, 8.}} )

In[19]:=

img3 = RenderData[adj, scaledShearData, DefaultColorForestGreen] ;

[Graphics:HTMLFiles/2_2d_graphics_26.gif]

Lay Example 2.7.4
Translated "N"

Use homogeneous coordinates.

In[20]:=

zs = Table[1, {k, 8}] ; 

data = {xs, ys} ;

homogeneousData = {xs, ys, zs} ;

%//MatrixForm

translate = ({{1, 0, 2}, {0, 1, 3}, {0, 0, 1}}) ;

Out[23]//MatrixForm=

( {{0, 0.5, 0.5, 6, 6, 5.5, 5.5, 0}, {0, 0, 6.42, 0, 8, 8, 1.58, 8}, {1, 1, 1, 1, 1, 1, 1, 1}} )

In[25]:=

<<Graphics`Graphics`

In[26]:=

viewWindow = {{-1, 12}, {-1, 12}} ; 

img4 = DisplayTogether[orig = RenderData[adj, data, DefaultColorOran ... [adj, ( translate . homogeneousData)[[{1, 2}, All]], DefaultColorForestGreen]] ;

[Graphics:HTMLFiles/2_2d_graphics_36.gif]

Lay Example 2.7.5
Rotated "N"

Use homogeneous coordinates.

In[28]:=

zs = Table[1, {k, 8}] ; 

data = {xs, ys} ;

homogeneousData = {xs, ys, zs} ;

%//MatrixForm

φ = π/6 ;

rot = ({{Cos[φ], -Sin[φ], 0}, {Sin[φ], Cos[φ], 0}, {0, 0, 1}}) ;

Out[31]//MatrixForm=

( {{0, 0.5, 0.5, 6, 6, 5.5, 5.5, 0}, {0, 0, 6.42, 0, 8, 8, 1.58, 8}, {1, 1, 1, 1, 1, 1, 1, 1}} )

In[34]:=

viewWindow = {{-4, 12}, {-4, 12}} ; 

rotData = ( rot . homogeneousData)[[{1, 2}, All]] ; 

img5 = RenderData[adj, rotData, DefaultColorOrchid] ;

[Graphics:HTMLFiles/2_2d_graphics_47.gif]

Lay Example 2.7.6
Composite Transformation

Use homogeneous coordinates.

In[37]:=

zs = Table[1, {k, 8}] ; 

data = {xs, ys} ;

homogeneousData = {xs, ys, zs} ;

%//MatrixForm ; 

scale = .3 IdentityMatrix[3] ; 

φ = π/2 ;

rot = ({{Cos[φ], -Sin[φ], 0}, {Sin[φ], Cos[φ], 0}, {0, 0, 1}}) ; 

translate = ({{1, 0, -.5}, {0, 1, 2}, {0, 0, 1}}) ; 

composite = translate . rot . scale ;

composite//MatrixForm

Out[46]//MatrixForm=

( {{0., -0.3, -0.15}, {0.3, 0., 0.6}, {0., 0., 0.3}} )

In[47]:=

compositeData = ( composite . homogeneousData)[[{1, 2}, All]] ; 

viewWindow = {{-4, 12}, {-4, 12}} ; 

img6 = RenderData[adj, compositeData, DefaultColorMediumSlateBlue] ;

[Graphics:HTMLFiles/2_2d_graphics_62.gif]

Lay Examples 2.7.1-6
Varieties of "N"

In[50]:=

letters = Show[GraphicsArray[{{img1, img2, img3}, {img4, img5, img6}}]] ;

[Graphics:HTMLFiles/2_2d_graphics_64.gif]


Created by Mathematica  (February 6, 2005) Valid XHTML 1.1!