Upload
d-g
View
212
Download
0
Embed Size (px)
Citation preview
This article was downloaded by: [George Mason University]On: 18 December 2014, At: 18:56Publisher: Taylor & FrancisInforma Ltd Registered in England and Wales Registered Number: 1072954 Registeredoffice: Mortimer House, 37-41 Mortimer Street, London W1T 3JH, UK
International Journal of MathematicalEducation in Science and TechnologyPublication details, including instructions for authors andsubscription information:http://www.tandfonline.com/loi/tmes20
Digital maps, matrices and computeralgebraD. G. Knighta Division of Mathematics and Statistics , University ofGlamorgan , Pontypridd, CF37 1DL, WalesPublished online: 10 Aug 2006.
To cite this article: D. G. Knight (2005) Digital maps, matrices and computer algebra,International Journal of Mathematical Education in Science and Technology, 36:4, 345-359, DOI:10.1080/00207390512331325932
To link to this article: http://dx.doi.org/10.1080/00207390512331325932
PLEASE SCROLL DOWN FOR ARTICLE
Taylor & Francis makes every effort to ensure the accuracy of all the information (the“Content”) contained in the publications on our platform. However, Taylor & Francis,our agents, and our licensors make no representations or warranties whatsoever as tothe accuracy, completeness, or suitability for any purpose of the Content. Any opinionsand views expressed in this publication are the opinions and views of the authors,and are not the views of or endorsed by Taylor & Francis. The accuracy of the Contentshould not be relied upon and should be independently verified with primary sourcesof information. Taylor and Francis shall not be liable for any losses, actions, claims,proceedings, demands, costs, expenses, damages, and other liabilities whatsoeveror howsoever caused arising directly or indirectly in connection with, in relation to orarising out of the use of the Content.
This article may be used for research, teaching, and private study purposes. Anysubstantial or systematic reproduction, redistribution, reselling, loan, sub-licensing,systematic supply, or distribution in any form to anyone is expressly forbidden. Terms &Conditions of access and use can be found at http://www.tandfonline.com/page/terms-and-conditions
International Journal of Mathematical Education inScience and Technology, Vol. 36, No. 4, 2005, 345–359
Digital maps, matrices and computer algebra
D. G. KNIGHT*
Division of Mathematics and Statistics, University of Glamorgan,Pontypridd, CF37 1DL, Wales
(Received 29 March 2004)
The way in which computer algebra systems, such as Maple�, have made thestudy of complex problems accessible to undergraduate mathematicians withmodest computational skills is illustrated by some large matrix calculations,which arise from representing the Earth’s surface by digital elevation models.Such problems are often considered to lie in the field of computer mapping andthus addressed by geographical information systems. The problems includesimple identification of local maximum points, visualization by cross-sectionalprofiles, contour maps and three-dimensional views, consideration of the visualimpact of the placement of large buildings and issues arising from reservoircreation. Motion through a virtual landscape can be simulated by an animationfacility. This approach has been successful with first year students: the ‘real world’problems considered are more accessible than many alternatives, and theattraction of using large matrices is retained.
1. Introduction
The advent of computer algebra systems has presented exciting opportunities forundergraduate mathematicians. These opportunities do not only include easy-to-usehigh quality graphical output, powerful equation solving and so on, but also a wayto learn a great deal about computer programming in a way that might be moreappealing than via a traditional high-level language. In this article we describehow the study of elementary programming by first year mathematicians can beenlivened by ambitious calculations involving large matrices and visualizationtechniques, all carried out in an integrated fashion using the Maple computeralgebra system.
One difficulty in carrying out hand calculations with matrices is the tediousnessinvolved, which easily leads to arithmetic error. Seldom would one wish to becomeinvolved with, say, finding the inverse of a matrix of order four. Although there aremany interesting problems involving small matrices (Strang [1] is a classic source),much of the glamour of successful application of mathematics to the ‘real world’ isassociated with problems where the matrices involved are very large and handled bycomputer programs. Here, unfortunately, the formulation of a particular problemin terms of matrices can involve a considerable amount of material unfamiliar tofirst year undergraduates: finite difference approximations to partial differential
International Journal of Mathematical Education in Science and TechnologyISSN 0020–739X print/ISSN 1464–5211 online # 2005 Taylor & Francis Group Ltd
http://www.tandf.co.uk/journalsDOI: 10.1080/00207390512331325932
*Email: [email protected]
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
equations in heat conduction problems, for example. We can, however, chooseproblems that can be considered to lie in the general subject area of computermapping, and thus treatable by what have become known as GIS (geographicalinformation systems). In this way the need for any specialist background knowledgeof physics or engineering can be avoided, as it is possible to find many interestingproblems involving the surface of the earth that are immediately and easilyunderstandable.
One way of storing information about the earth’s surface is by a digital elevationmodel (DEM) in which the terrain is represented by spot heights given at regularintervals on a rectangular grid. This grid DEM is a simple example of a digital mapand the heights can be interpreted as the elements of a matrix. As can be seen froma text such as Chrisman [2], or software such as ESRI’s ArcView, the generation,accuracy and use of grid DEMs is just one aspect of the many matters with whichcomputer mapping and GIS concern themselves. Grid DEMs are, however, afundamental construct and particularly useful in such matters as creating flexiblecontour maps, investigating the visibility of large structures such as wind turbines,calculating sunset times, and associated problems [3–8].
Given a matrix of spot heights, typical questions that could be asked are:
(a) Discover the highest and lowest elevations on a particular piece of terrain,i.e. what are the maximum and minimum elements in the matrix?
(b) Can you locate heights (‘local maxima’) which are greater than theirimmediate neighbours?
(c) Can you produce a three-dimensional view of the terrain?(d ) Can you create a contour map of the terrain?(e) What would the terrain look like if it were flooded?( f ) In the event of (e), how much water would a valley hold if converted to
a reservoir?(g) How would the terrain look if large buildings were added?(h) Taking one specified point on the terrain (P, say) can you construct the
ground profile to some other specified point P 0?(i) Could a person at P see P 0?( j) Can you subsequently determine the entire area visible from P?(k) Can you arrange to ‘zoom in’ on a particular part of the landscape?(l ) Can you animate the 3D views in (c) or (k) so you ‘move’ through a virtual
landscape?
2. Using small matrices to illustrate the problems posed in the introduction
Consider matrices
A ¼
10 11 10 2
12 25 27 3
8 23 17 4
6 15 6 2
266664
377775, B ¼
15 15 15 15
15 25 27 15
15 23 17 15
15 15 15 15
266664
377775
and C ¼
10 100 100 2
12 100 100 3
8 23 17 4
6 15 6 2
266664
377775
where the elements Ai, j of matrix A are considered to be heights (in metres) abovesea-level taken at 100 metre intervals on some part of the earth’s surface.
346 D. G. Knight
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
We now consider, in turn, the problems (a)–(l ) posed earlier, using A as anexample:
(a) The largest element in A is 27 and the smallest is 2.(b) Restricting attention to ‘interior’ elements of A, i.e. elements with a full set
of eight neighbours, the elementA2, 3 ¼ 27 is the only local maximum,i.e. it is the only element greater than all its immediate neighbours (11, 10,2, 25, 3, 23, 17 and 4).
(c, d ) When viewed in reality, or when contoured, A is a hill with a steep easternslope.
(e) If we set all heights in A which are less than some height H, to equal H,then when H ¼ 15 we get matrix B. We can imagine that B representsterrain flooded to a level of 15 metres above sea-level, and we can displayB in a similar manner to (c) above.
( f ) If V denotes an approximate value for the volume of water in cubic metresneeded to create B from A, there is no hard and fast way of obtaininga value for V. We could, for example, let SAði, jÞ denote the small squareof terrain enclosed by the elements Ai, j, Ai�1, j, Ai�1, jþ1, Ai, jþ1, i.e. Ai, j andthe three heights immediately above and to the right, and take Ai, j torepresent the height of the terrain throughout SAði, jÞ. Then, if Ai, j <H,this terrain square contributes 1002ðH � Ai, jÞm3 to V. Using the partic-ular A and B above, this approach gives V ¼ 280,000m3.
( g) If we set the heights of some square SAði, jÞ to a value Y, then whenY ¼ 100, and the square is SAð2, 2Þ, we get matrix C. We might imagine Cas attempting to represent, in a simplistic way, terrain with a largestructure added.
(h) To create a profile of the terrain between two given heights Ap, q ¼ P1,and Ar, s ¼ Pm, we need to begin by finding values for Pi, i ¼ 2, . . . ,m� 1.Figure 1(a) illustrates this situation, taking P1¼A4, 1 and Pm¼P5¼ A1, 2.If we identify Pi as lying in SAðu, vÞ, as in figure 1(b), then we can estimatethe height Pi by a formula such as
Pi �1
4½Au, v þ Au�1, v þ Au�1, vþ1 þ Au, vþ1� ð1Þ
Thus, in our example, we find P2 ¼ 13,P3 ¼ 17, and P4 ¼ 14:5.
(a) (b) (c)
•
•
•
•
•
•
•
•••
•A(1,1) P(5)
P(4)
P(2)
P(1)
P(3)•
•
•
•
••
P(i)
u−1, v
u, v
u − 1, v + 1
u , v +1
Figure 1. Constructing a profile from Ap, q ¼ A4,1 ¼ P1 to Ar,s ¼ A1,2 ¼ P5.
Digital maps, matrices and computer algebra 347
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
The profile is then produced by a plot of Pi against i, as shown in
figure 1(c).
For each i, the values of the integers u and v can be found by dividing
the distance between rows p and r, and between columns q and s, into
equal intervals and then rounding, i.e. u ¼ pþ u0d e and v ¼ qþ v0b c,
where b c and d e denote the floor and ceiling functions, and
u0 ¼ði � 1Þðr� pÞ
m� 1, v0 ¼
ði � 1Þðs� qÞ
m� 1
When r ¼ p ¼ 1 or s ¼ q ¼ n, we take u ¼ 2 and v ¼ n� 1 respectively, to
avoid using u ¼ 1 and v ¼ n in equation (1).
(i) A person of height h ¼ 2m, standing at P1 in figure 1(c), can see P2 but no
other profile point, and in particular can’t see P5. Establishing the
intervisibility, or otherwise, of profile endpoints involves considering
the slopes Si, ði ¼ 2, . . . ,mÞ, of the lines joining the point at
Q ¼ Pi þ h, to P2,P3, . . . , Pm (figure 2 shows two example profiles). We
ignore the effect of the curvature of the earth, which is very small over the
distances under consideration. The Si are given by
Si ¼Pi �Q
i � 1
and if any Si > Sm, ði ¼ m� 1,m� 2, . . . , 2Þ, then the profile endpoints
are not intervisible.
( j) Thus, given P, the entire area visible from P can be established by
investigating all Ai, j for intervisibility.
(k) We can illustrate zooming-in on part of the terrain represented by A by
concentrating on some zxz submatrix A(r, c, z) whose corners are Ar,c,
Ar,cþz�1, Arþz�1,c, Arþz�1,cþz�1, where r, c and z are assumed to be
sensible. Thus for matrix C, a display of C(1, 1, 2) would show flat terrain
at an elevation 100 metres.
(l ) Finally, an animated movement sequence could be produced by
preparing a succession of views at different zoom levels, and displaying
them in turn.
Q
P(1) P(2)
P(3)
h
P P(5)
P P(5)Q
P(1) P(2)
line of sight
h
i i
(a) (b) Figure 2. The intervisibility problem for representative profiles: (a) Q can see P5. P2, P3
and P4 are below the line of sight. (b) Q can’t see P5. P3 is above the line of sight. (S3>S5,where S3 and S5 are the slopes of QP3 and QP5).
348 D. G. Knight
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
3. Maple code to solve our problems
An excellent brief introduction to Maple can be found in [9], with fuller detail
available in standard sources such as [10]. The Maple code which follows is available
from the author via e-mail. Wherever possible the code uses traditional program-
ming language features, and deliberately uses ‘for’ loops to handle matrices, not
Maple-specific constructs.
We begin by creating our 4� 4 matrix A:
n:¼4: A:¼matrix(n,n,[[10,11,10,2],[12,25,27,3],[8,23,17,4],[6,15,
6,2]]):
(a) The largest element M, and the smallest m, can be found in straightforward
fashion by
M:¼A[1,1]: m:¼A[1,1]:
for i from 1 to n do for j from 1 to n do
if A[i,j]>M then M:¼A[i,j]: fi: if A[i,j]< m then m:¼A[i,j]: fi:
od: od:
lprint(‘largest¼‘,M,‘ smallest¼‘,m);
‘largest¼‘, 27, ‘ smallest¼‘, 2
(b) Creating code for finding local maxima is less easy for the beginner. One
possibility is:
for i from 2 to n-1 do for j from 2 to n-1 do # using 2 & n-1 avoids map
edges
if A[i,j]>A[i-1,j-1] and A[i,j]>A[i-1,j] and A[i,j]>A[i-1, jþ1]
and A[i,j]>A[i,j-1] and A[i,j]>A[i,jþ1]
and A[i,j]>A[iþ1,j-1] and A[i,j]>A[iþ1,j] and A[i,j]>A [iþ1,jþ1]
then
lprint(‘ local maximum‘,A[i,j],‘ at ‘(i,j));
fi:
od: od:
‘local maximum‘, 27,‘ at ‘(2,3)
(c) Maple can produce three-dimensional views using its matrixplot command
from the plots package. Once obtained, the plot can be rotated on screen.
The simplest way to use matrixplot, giving figure 3(a), is:
with (plots): matrixplot(A);
The way in which the view is displayed by matrixplot can be controlled
and improved by a number of options. A solid surface is obtained bystyle¼patch and contours only by style¼contour. The viewing direction
is defined by orientation¼ [theta,phi], where theta and phi are spherical
polar horizontal and vertical angles. The height range to be displayed is
specified by view¼[low..high]. The axes and shading options allow
variation of axes and shading. Figure 3(b) shows the output generated by
matrixplot(A,style¼patch,axes¼boxed,view¼0..45,orientation¼[-
20,70],shading¼XY);
Digital maps, matrices and computer algebra 349
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
In figure 3(c) we display a plot of A in histogram style:
matrixplot(A, heights¼histogram, gap¼0.0, axes¼frame,
orientation¼[�35,40], style¼patch, color ¼green);
(d ) Choosing style¼contour and orientation¼[0,0], followed by
matrixplot(A,style¼contour,contours¼[10,15,25],orientation¼[0,0],
axes¼boxed,colour¼black );
produces a traditional contour plot (figure 3(d)). The particular contours
were specified with contours¼[a,b..], where a,b.. are contour values,
and colour¼black avoided default colour choices. Maple doesn’t label the
contours, and any required labelling is added manually via the Paint graphics
program.
(e) Next we create B, the flooded landscape shown in figure 4(a).
B:¼matrix(n,n): H:¼15:
for i from 1 to n do for j from 1 to n do
if A[i,j]<H then B[i,j]:¼H: else B[i,j]:¼A[i,j]: fi:
od: od:
matrixplot(B,axes¼boxed,view¼0..45,style¼patch,orientation¼[-
20,70],shading¼XY);
(a) (b)
(c) (d)Figure 3. Using matrixplot in simple, improved, histogram and contour styles.
350 D. G. Knight
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
( f ) The approximate volume V is easily found:
V:¼0:
for i from 2 to n do for j from 1 to n-1 do
if A[i,j]<H then V:¼Vþ(H-A[i,j])*100*100: fi:
od: od:
lprint(‘volume¼‘,V,‘cubic metres‘);
‘volume¼‘, 280000,‘cubic metres‘
(g) Now we create C, the terrain with a simple building added, as displayed in
figure 4(b):
C:¼matrix(n,n): II:¼2: J:¼2: Y:¼100: # I is a reserved word: I^2 ¼ -1
for i from 1 to n do for j from 1 to n do C[i,j]:¼A[i,j]: od: od:
C[II,J]:¼Y: C[II,Jþ1]:¼Y: C[II-1,J]:¼Y: C[II-1,Jþ1]:¼Y:
matrixplot(C,axes¼boxed,view¼0..105,style¼patch, orientation¼[-
20,70],shading¼XY);
(h) We begin profile construction by calculating the heights Pi of the profile
between P1 and P5, following the equations presented earlier.
m:¼5: p:¼4: q:¼1: r:¼1: s:¼2: P:¼vector(m): P[1]:¼A[p,q]:
P[m]:¼A[r,s]:
for i from 2 to m-1 do
u:¼ p þ ceil((i-1)*(r-p)/(m-1)): v:¼ q þ floor((i-1)*(s-q)/(m-1)):
P[i]:¼0.25*(A[u,v]þA[u-1,v]þA[u-1,vþ1]þA[u,vþ1]):
od:
print(‘profile heights‘,P);
profile heights, [6, 13.00, 17.00, 14.50, 11]
Now figure 1(c) can be recovered by plotting Pi against i.
points:¼seq([k,P[k]],k¼1..m):
pq:¼plot([points],colour¼black,style¼point,symbol¼box,
symbolsize¼12):
pqq:¼plot([points],colour¼grey,filled¼true):
display([pq,pqq],labels¼[‘i ‘,‘P ‘],labelfont¼[TIMES, ROMAN,14]);
(a) (b)Figure 4. Views of B and C.
Digital maps, matrices and computer algebra 351
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
(i) The intervisibility of P1 and P5 is checked by the calculation involving theslopes Si. We rediscover that a person at P1 can’t see P5.
h:¼2: Q:¼P[1]þh: S[m]:¼(P[m]-Q)/(m-1): can_see:¼true:for i from m-1 by -1 to 2 do
S[i]:¼(P[i]-Q)/(i-1): if S[i]>S[m] then can_see:¼false: break: fi:
od:
ifcan_see¼truethenlprint(‘visible‘):elselprint(‘notvisible‘):fi:
‘not visible‘
( j) By checking all possible Ar,s from the viewpoint at P1, using some sensiblevalue of m for each check, we can produce a matrix W with entries either 1or 0, depending on whether Ar,s is visible or not. This effectively determinesthe entire area visible from P1. Such a view is sometimes referred to as a‘viewshed‘, or, in a military context, a ‘weapons fan’.
W:¼matrix(n,n): Q:¼A[p,q]þh:for r from 1 to n do for s from 1 to n do # check A[r,s]
m:¼abs(r-p)þabs(s-q)þ1: P:¼vector(m): P[m]:¼A[r,s]:
if m¼1 or m¼2 then W[r,s]:¼1: else
for i from 2 to m-1 do
u:¼pþceil((i-1)*(r-p)/(m-1)): v:¼qþfloor((i-1)*(s-q)/(m-1)):
if u¼1 then u:¼2: fi: if v¼n then v:¼n-1: fi:
P[i]:¼0.25*(A[u,v]þA[u-1,v]þA[u-1,vþ1]þA[u,vþ1]):
od:
S[m]:¼(P[m]-Q)/(m-1): can_see:¼true:
for i from m-1 by -1 to 2 do
S[i]:¼(P[i]-Q)/(i-1):
if S[i]>S[m] then can_see:¼false: break: fi:
od:
if can_see¼true then W[r,s]:¼1:else W[r,s]:¼0: fi:
fi:
od: od:print(‘W¼‘,W);
w ¼
½ 0 0 0 0 �
½ 0 1 0 0 �
½ 1 1 0 0 �
½ 1 1 0 0 �
(k, l) We postpone looking at zooming and animation, since A is rather too smallto illustrate them effectively.
Having demonstrated that our code is successful for a 4�4 matrix, we next turnto realistic geographical data.
4. Large matrices: digital maps
Ordnance Survey� digital elevation data (� Crown copyright, all rights reserved ) ofa 5 km� 5 km area near the University of Glamorgan can be used to produce a large
352 D. G. Knight
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
matrix. If the data is held in a file ‘MAP.DAT’ such that the file contains fifty lines,
each line with fifty integers, then the code below creates A as a 50� 50 array. The
code also prints submatrix A(1,1,10), i.e. the top left corner of the terrain.
n:¼50: # n is the number of columns in the file
readlib(readdata): A:¼readdata(‘map.dat‘,n): A:¼convert(A, matrix):
r:¼1: c:¼1: z:¼10: partA:¼matrix(z,z): # ready to zoom in on top left
for i from r to rþz-1 do for j from c to cþz-1 do
partA[i-rþ1,j-cþ1]:¼A[i,j]:
od: od:
lprint(‘100 of the 2500 elements in A (top left corner)‘); print(partA);
‘100 of the 2500 elements in A (top left corner)‘
½ 207: 205: 201: 212: 204: 197: 192: 176: 139: 157: �
½ 209: 207: 203: 219: 212: 205: 191: 149: 120: 132: �
½ 210: 209: 206: 203: 201: 212: 175: 142: 124: 108: �
½ 209: 210: 209: 207: 205: 200: 160: 143: 126: 101: �
½ 206: 208: 211: 207: 212: 175: 156: 141: 128: 98: �
½ 209: 198: 195: 186: 177: 165: 151: 137: 118: 98: �
½ 181: 177: 180: 179: 171: 160: 148: 128: 110: 95: �
½ 173: 170: 174: 174: 170: 157: 140: 118: 104: 86: �
½ 147: 151: 164: 168: 165: 151: 132: 112: 97: 75: �
½ 108: 124: 138: 149: 149: 137: 118: 106: 90: 68: �
Apart from the fact that the array size has changed, the same code as presented in
section 3 can now be used immediately to discover that:
(a) The highest and lowest points in the area are 280m and 35m.
(b) There are 31 local maxima. A list of these maxima begins: A2,4 ¼ 219, A5,3 ¼211, A5,5 ¼ 212, and can thus be checked within the fragment of A shown
above. In addition the overall high value 280 is also shown to exist as a local
maximum at A5,35.
(c, d ) More interesting is producing the displays in figures 5 and 6 by
with(plots): c1:¼45: c2:¼75: c3:¼155: c4:¼235: # c1.. are contour values
matrixplot(A,axes¼boxed,orientation¼[0,0],style¼contour,
contours¼[c1,c2,c3,c4],colour¼ black);
Figure 5. The contours of the Taff valley.
Digital maps, matrices and computer algebra 353
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
matrixplot(A,axes¼boxed,style¼patch,view¼30..400,
orientation¼[51,68]);
The main feature of the terrain is the Taff valley, running from north-west to
south-east, with mountains on both sides, and with the Rhondda joining
from the west. Figure 6 looks north-west along the Taff valley. Although
devoid of the buildings which cover the valley floor, this view is easily
recognisable by someone familiar with the actual, rather rural, landscape.
(e) To create a flooded landscape we take, as flood level H, three-fifths of the
greatest height, i.e. H ¼ 168. Again the code is otherwise as in section 3,
with the figure 7 produced by
matrixplot(B,axes¼boxed,style¼patch,view¼30..400,orientation¼
[51,68]);
( f ) We also find that the flooded area would contain approximately
938,170,000m3 of water, which is almost one cubic kilometre.
(g) To create a landscape with a simple added structure, we use value I ¼ 30,
J ¼ 20, and Y ¼ 300 to give a new C, in a similar fashion to section 3(g),
and produce figure 8(a) with
matrixplot(C,axes¼boxed,style¼patch,view¼30..400, orientation¼
[51,68]);
Of course we could add structures in a more sophisticated way than
merely adjusting terrain heights. Figure 8(b) illustrates with a hypothetical
wind-farm. Starting with our original terrain matrix A, we add six turbines
to the landscape using Maple’s cone-drawing facility.
Figure 6. Maple view of the Taff valley.
Figure 7. The flooded landscape.
354 D. G. Knight
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
viewA:¼matrixplot(A,axes¼framed,orientation¼[26,62],view¼0..420):
tx:¼10:ty:¼25:
for g from 1 to 6 do
tz:¼A[tx,ty]:
tower[g]:¼cone([tx,ty,200þA[tx,ty]],1,200,color¼gray,style¼
patchnogrid):
tx:¼txþ4:ty:¼tyþ4:
Tower[g]:¼display([viewA,tower[g]],scaling¼unconstrained):
od:
mysequence:¼[seq(Tower[gg],gg¼1..6)]: display(mysequence);
(h) We illustrate profile creation with figure 9, taken across the steep-sided
Rhondda Valley in the north-west corner of the map. The profile begins at P1
¼ Ap,q ¼ A2,2 and ends at P30 ¼ Ar,s ¼ A30,10.
(i, j) To demonstrate the intervisibility problem we increase a single spot height
S¼A30,20 to 300m, and determine the area that is visible from this point.
Figure 10 is achieved by creating and contour-plotting a matrix W, with
elements 0 or 1, as before:
matrixplot(W,axes¼boxed,orientation¼[0,0],style¼contour,contours¼
[0.5]);
S is marked by a cross added to the diagram, and the area not in the viewshed
has been shaded. Naturally anyone living within the viewshed might com-
plain about visual intrusion.
(a)
(b)Figure 8. (a) The terrain with large structure added. (b) The terrain with a wind-farm added.
Digital maps, matrices and computer algebra 355
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
(k) We return to the issue of zooming in on part of the landscape by taking acloser look at a tower of elevation Y ¼ 240 at ðI , JÞ ¼ ð30, 20Þ, combined
with a flood height H ¼ 140. A matrix E is formed from A, using the newvalues of Y, I, J and H. Then sub-matrix E(24,10,20) is created using codesimilar to that used at the very start of section 4 to create sub-matrix
A(1,1,10). Figure 11 then follows from
matrixplot(partE,axes¼framed,orientation¼[35,65],view¼ 110..320);
(l) The last issue to be visited is animation. This essentially visual featureis particularly well-suited to the display of solutions to time-dependent
problems. Animations can be played by right-clicking on the diagram, andthen selecting ‘animation’ and ‘play’. Naturally a smoother animation can beproduced by including more frames in the animated sequence. There is, of
course, somewhat less scope for animation in problems involving geographiclandscapes, due to their somewhat static nature, but nevertheless we presentthe frames of two simple animations.
The first animation (figure 12) is intended to simulate the flooding of the valley, andis produced from our original matrix A,with six flood-levels: 70m, 100m, . . . , 220m.
B:¼matrix(n,n): H:¼40: mm:¼array(1..6): # A is in existence
for hh from 1 to 6 do
H:¼Hþ30:
Figure 9. Profile across the Rhondda Valley.
Figure 10. An intervisibility map.
356 D. G. Knight
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
for i from 1 to n do for j from 1 to n do
if A[i,j]<H then B[i,j]:¼H: else B[i,j]:¼A[i,j]: fi:
od: od:
m[hh]:¼matrixplot(B,axes¼boxed,style¼patch,
view¼30.. 400,orientation¼ [51,68]);
od:
myseq:¼[seq(m[HH],HH¼1..6)]: display(myseq,insequence¼true);
The second animation simulates an aerial approach to a structure in the
flooded valley.
Having obtained matrix E in (k) above, we continue by creating sub-matrices
F [1], F [2] . . . F [10], which contain enlarged views of increasingly smaller parts of
E, and then plotting these sub-matrices.
nf:¼10: # the number of frames
for i from 1 to nf do F[i]:¼matrix(n,n,0):od:
for i from 1 to n do for j from 1 to n do F[1][i,j]:¼E[i,j]: od: od:
r:¼6: c:¼5: z:¼42:
for k from 1 to nf-1 do
for i from 1 to 50 do for j from 1 to 50 do
Figure 12. A six-frame sequence showing the valley being flooded.
Figure 11. A magnified view of part of the terrain.
Digital maps, matrices and computer algebra 357
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
u:¼rþceil((i-1)*z/n): v:¼cþfloor((j-1)*z/n):
F[kþ1][i,j]:¼1.05*F[k][u,v]:
od: od:
od:
for k from 1 to nf do
p[k]:¼matrixplot(F[k],axes¼none,orientation¼[45,65],
view¼[1..49,1..49,130..530],shading¼none):
od:
myseq:¼[seq(p[kk],kk¼1..nf)]:display(myseq,insequence¼true);
Figure 13 shows frames 2–10 of the animation.
5. Conclusions
A computer algebra system with good graphics facilities can reproduce the essentialfeatures of a geographical information system, and in particular the underlyingmatrix manipulation involved with digital elevation data. Such an applicationhas allowed first-year undergraduate mathematicians to enjoy tackling interestingcontemporary problems, and create imaginative matrix-handling programs.
References
[1] Strang, G., 1988, Linear Algebra and Its Applications (Saunders, H.B.J. College Publishers).[2] Chrisman, N.C., 2001, Exploring Geographic Information Systems (Wiley).[3] Kidner, D.B., 1997, The role of GIS in wind farm planning, In Geographical Information
’97: Third Joint European Conference and Exhibition on Geographical InformationProceedings, Vienna, Austria, edited by S. Hodgson, M. Rumor and J.J. Harts (IOS Press)pp. 843–852.
[4] Struthers, A., 1996, Creating topographic maps from online data using Mathematica,Mathematica in Education and Research, 5, 24–28.
[5] Acavedo, W., and Masuoka, P., 1997, Time-series animation techniques for visualizingurban growth, Computers & Geosciences, 23, 423–435.
[6] Kalmar, J., Papp, G., and Szabo, T., 1995, DTM-based surface and volumeapproximation. Geophysical applications, Computers & Geosciences, 21, 245–257.
Figure 13. A sequence of nine frames showing motion through the landscape.
358 D. G. Knight
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014
[7] Dorey, M.I., 2002, Digital Elevation Models for Intervisibility Analysis and VisualImpact Assessment. PhD thesis, University of Glamorgan.
[8] Keller, C., and Hall, J.K., 2000, Using a digital terrain model to calculate visual sunriseand sunset times, Computer & Geosciences, 26, 991–1000.
[9] McKeown, G.P., 1999, Specifying and simulating rotor machines using Maple,International Journal of Mathematical Education in Science and Technology, 30, 867–887.
[10] Monagan, M.B., Geddes, K.O., Heal, K.M., Labahn, G., Vorkoetter, S.M., andCarron, J., 2000, Maple 6 Programming Guide (Waterloo: Maple Inc.).
Digital maps, matrices and computer algebra 359
Dow
nloa
ded
by [
Geo
rge
Mas
on U
nive
rsity
] at
18:
56 1
8 D
ecem
ber
2014