schematics.mws

MathClass Lesson 4:

Schematic Diagrams

In this lesson, you will learn how to construct more general schematic diagrams, adding walls, arrows, texts and multicolored boundaries. As a special application, we'll use these tools to draw stick figures complete with facial features, clothing, and labels for their name and height.

Introduction

Example: A standard calculus problem asks for the largest rectangular area that can be bounded by a fixed amont of fencing if one edge of the enclosure lies on an extant wall. Construct a diagram to illustrate this problem

Solution:

The problem asks for a picture something like the one below:

[Maple Plot]

Here we take advantage of the fact that we can make lines of different thicknesses.

In keeping with our desire to make every aspect of the diagram a function of our choice of points (up to text offsets) we place the label for the wall at approximately the point midway between the two points of contact of the fence with the wall - with an appropriate offset. Note the "scaling = constrained" option in the plots[display] command. This forces Maple to use rectangular coordinates where the scales on the x- and y-axes are the same. In the absence of this command Maple tries to adjust the aspect ratio of the figure to display the most information in the space available. While very useful this is not always exactly what we want to see. The reader should remove the option and observe the results.

> restart;

> libname := "C:/mylib/MathClass", libname;

> A:=[0,0]:

> B:=[0,1]:

> C:=[2,1]:

> DD:=[2,0]:

> E:=[-1,0]:

> F:=[3,0]:

> FNC:=MathClass[DL](A,B,2,1,green),MathClass[DL](C,B,2,1,green),MathClass[DL](C,DD,2,1,green):

> WLL:=MathClass[DL](E,F,9,1,orange):

> TXT:=MathClass[PT](1/2*(A+DD)+[0,-.3],`Wall`,16,blue):

> plots[display]([FNC,WLL,TXT],scaling=constrained,axes=none);

[Maple Plot]

Placing a Graph on Graph Paper

One frequently finds it convenient to place a graph on "graphpaper" rather than simply have it located relative to coordinate axes with tickmarks. The command GP (for "graph paper" ) is useful for doing this. Its syntax is:

MathClass[GP](llcorner,width, length, resolution, font) , where

llcorner = the point [a,b] which is the lower left corner of the graphpaper

width = the width of the graphpaper

length = the length of the graphpaper

resolution = number of grid squares sides covering the interval [0,1] . The values 1,2,3,4 are the most common.

font = font in which tickmarks are printed

Note: A fontsize of 1 gives no tickmarks ( this is used very frequently). GP is primitive - it puts tickmarks only at integer values.

> MathClass[GP]([-2,-2],10,10,1,12,red);

[Maple Plot]

> gp:=MathClass[GP]([-2,-2],6,6,1,1,red):
gp;

Had we wanted to place the previous wall diagram on this graph paper we simply

[Maple Plot]

> plots[display]([FNC,WLL,TXT,gp],scaling=constrained,axes=none);

Coordinates from Graphs

Clicking the cursor on a point in a plot will cause the coordinates of the point to be displayed ia small window that replaces the paragraph style in text mode. Unfortunately Maple provides no means for a Maple procedure to access these coordinates. However one can copy and paste them in the process of diagram construction and this is often very useful. For instance suppose we want to select a point visually in the wall diagram and connect it to the upper corner by a dotted line. We could, as in the previous paragraph, overlay the original diagram on graph paper and acquire approximate coordinates for the point of interest in that manner. However we can also place the cursor at a point on a diagram, left click the mouse, and read the coordinates

[Maple Bitmap]

In the diagram we could copy the "1.92, 1.72" from the toolbar and paste it into, say, a MathClass[DL] command. Note that the coordinates in the window are a sequence rather than a list. Thus if they are pasted over "location" in MathClass[DL](location, [2,3],2,4,red) the result will be MathClass[DL](1.92, 1.72, [2,3],2,4,red) which won't work due to the missing "[]" pair which.They need to be added to produce MathClass[DL]([1.92, 1.72], [2,3],2,4,red) , which will work.

[Maple Plot]

Excercise(s): Construct the following figures

a. [Maple Plot] (The colors are red, green, and orange).

b. [Maple Plot] (The colors are green, orange, red, magenta; the thicknesses are 2,5,6,8).

c. [Maple Plot] ( the broken linestyle is 4. Note the appearance of broken, dotted, dashed linestyles is will change as image sizes are adjusted. When the images shrinks dashed lines appear continuous. This is less pronounced on thin lines)

d. [Maple Plot] (the dashed linestyle is 4)

a code

> A:=[0,0]:

> B:=[1,0]:

> C:=[1,1]:

> LNS:=MathClass[DL](A,B,3,1,red),MathClass[DL](A,C,3,1,green),MathClass[DL](B,C,3,1,orange):

> TRNG:=plots[display]([LNS],axes=none):
TRNG;

[Maple Plot]

b code

> A:=[0,0]:

> B:=[1,0]:

> C:=[1,1]:
DD:=[0,1]:

> LNS:=MathClass[DL](A,B,5,1,red),MathClass[DL](A,DD,2,1,green),MathClass[DL](B,C,6,1,orange),MathClass[DL](DD,C,8,1,magenta):

> TRNG:=plots[display]([LNS],axes=none):
TRNG;

[Maple Plot]

c code

> A:=[0,0]:

> B:=[1,0]:

> C:=[1,1]:
DD:=[0,3/4]:
E:=[0,1]:
F:=[1,1/4]:
G:=[1/2,1/4]:
H:=[1/2,1]:
II:=[-1/2,7/8]:
J:=[1/4,7/8]:
K:=[1/4,1/8]:
L:=[5/4,1/8]:

> LNS:=MathClass[DL](A,B,3,1,blue),MathClass[DL](A,DD,3,1,blue),MathClass[DL](F,C,3,1,blue),MathClass[DL](E,C,3,1,blue),MathClass[DL](G,H,3,1,blue):
PTH:=MathClass[DL](II,J,2,4,red),MathClass[DL](J,K,2,4,red),MathClass[DL](K,L,2,4,red):

> TRNG:=plots[display]([LNS,PTH],axes=none,scaling=constrained):
TRNG;

[Maple Plot]

d code

> A:=[0,0]:

> B:=[1,0]:

> C:=[1/2,0]:
DD:=[1/2,3/4]:

> LNS:=MathClass[DL](A,B,3,1,blue),MathClass[DL](DD,C,3,3,blue):
TXT:=MathClass[PT](A+[-.1,-.1],"A",30,red),MathClass[PT](B+[.1,-.1],"B",30,red),MathClass[PT](C+[.1,.1],"C",30,red),MathClass[PT](DD+[0,.1],"D",30,red):

> RTANGL:=MathClass[DL](C-[.2,0],C-[.2,0]+[0,.2],1,4,black),MathClass[DL](C-[.2,0]+[0,.2],C+[0,.2],1,4,black):

> TRNG:=plots[display]([LNS,TXT,RTANGL],axes=none,scaling=constrained):

> TRNG;

[Maple Plot]

More Complex Figures:

As we add additional tools the importance of a systematic approach will become more and more evident. Even for the previous, simple diagrams we have emphasized the importance of separately identifying the reference points for the diagram and constructing the instructions relative to those points. In this section the addition of circles, circular arcs, and arrows will greatly expand the complexity of the figures we can produce.This will make adherence to the principle of i dentifying the problem reference parameters and constructing the basic figure realtive to them even more important.

Adding Circles and Arrows to Diagrams

MathClass[PC](center, radius, thickness, linestyle, color) "place circle" draws a circle with the specified radius, line thickness, linestyle, and color centered at the specified point.

> MathClass[PC]([1,2],1,3,1,green);

Note that MathClass[PC] does not automatically invoke "scaling = constrained" or "axes=none" since sometimes one wants to omit one or both of them. Those options are specified in the final plots[display] statement. Thus the circles it returns may appear elliptical when viewed independently. CLicking on the plot and then selecting "1-1" at the toolbar will render it constrained. This can also be done by right clicking on the plot, selecting "projection" and then "constrained".

[Maple Plot]

Very similar to MathClass[PC] is MathClass[PA] for "place arc" it has the form

MathClass[PA](center, radius, theta1, theta2, thickness, linestyle, color) draws the circular arc with the specified thickness and linestyle along the circle described parametrically by P(t) = center + radus*[cos(t), sin(t)] which corresponds to the values of t between theta1 and theta2. The same observation regarding scaling and axes apply to MathClass[PA] as to MathClass[PC] .

> MathClass[PA]([1,2],1, 5*Pi/4, 7*Pi/4, 3,1,green);

[Maple Plot]

MathClass[ARRW](A,B, colr,DH or SH, scalefactor) draws an arrow from point A to point B of the specified color. "DH" specifies a double-headed arrow and "SH" a single headed arrow. The argument "scale factor" is the ratio of the shaft thickness to the arrow length and is generally a number between .01 and .05. It generally must be adjusted to taste.

Note: ARRW is a simplification of Maple's plottools[arrow] command which gives the user more control over the shape of the arrow head. ARRW is a compromise that usually provides acceptable results.

> MathClass[ARRW]([0,0],[1,1],magenta,`DH`,.03);

[Maple Plot]

> plots[display](MathClass[ARRW]([1,2],[0,1],magenta,`SH`,.02));

[Maple Plot]

Example 1: Draw a "male" stick figure

Solution: There is of course no single solution. The figure below is crude but would satisfy the requirements. We have included labels for a number of points which we will suppress in the final version. Their purpose is to emphasize the basic organizational principle of first identifying and labeling parameters for the components of a figure and then constructing the figure relative to those points. A hand sketch is often useful in getting started.

[Maple Plot]

Note that we execute each of these lines as we enter them. This catches many errors. If everything works up to a line and then an error appears at that point we know that line contributed to the problem.

code for stickman

>
#Face parameters

> HDCNTR:=[0,4.5]:# head center

> HDRDS:=.5:# head radius

> HDCLR:=blue: #head color

>
#eyes

> LEYCNTR:=[-.2,4.7]: # left eye center

> REYCNTR:=[.2,4.7]:# Right eye center

> EYCLR:=red:# eye color

> EYRDS:=.1: #Eye radius

>
#smile

> SMLCNTR:=[0,4.7]: #smile center

> SMLRDS:=.4: #smile radius

> SMLANGL1:=5*Pi/4:

> SMLANGL2:=7*Pi/4:

> SMLCLR:=green:# smile color

>
#body parameters

> BDYTP:=[0,4]: #body top

> BDYBDM:=[0,1]: #body bottom

> BDYCLR:=magenta: #body color

> #arms

> LHND:=[-2,3]: #left hand

> RHND:=[2,3]: #right hand

> SHLDR:=[0,3.5]:#shoulder(s)

> ARMCLR:=blue: #arm color

>
#legs

> LFT:=[-1,0]: #left foot

> RFT:=[1,0]: #right foot

> LGCLR:=red: # foor color

>
#construction of body components

> FACE:= MathClass[PC](HDCNTR,HDRDS,3,1,HDCLR):

> EYES:=MathClass[PC](LEYCNTR,EYRDS,3,1,EYCLR),MathClass[PC](REYCNTR,EYRDS,3,1,EYCLR):

> SML:=MathClass[PA](SMLCNTR,SMLRDS,SMLANGL1,SMLANGL2,3,1,SMLCLR):

> BDY:=MathClass[DL](BDYTP,BDYBDM,3,1,BDYCLR):

> ARMS:=MathClass[DL](LHND,SHLDR,3,1,ARMCLR),MathClass[DL](RHND,SHLDR,3,1,ARMCLR):

> LGS:=MathClass[DL](LFT,BDYBDM,3,1,LGCLR),MathClass[DL](RFT,BDYBDM,3,1,LGCLR):

>
#assemble figure

> STICKMAN:=plots[display]([LGS,ARMS,BDY,SML,EYES,FACE],scaling=constrained,axes=none):

> STICKMAN;

[Maple Plot]

Example 2: Modify the stickman by inserting an arrow pointing to him indicating that he is Joe.

[Maple Plot]

Solution: The following fits the requirements.

The idea, of course, is to regard the arrow and associated text simply as additional components to be added to the current figure. In this case we can regard the arrow and name as making up a component to which we assign the label "HSNAME" which will be consist of an arrow and some text.

HSNAME:=MathClass[ARRW](NMARTL,NMARHD,,NMARCLR, `SH`, NMARSCLFCT),MathClass[PT](NMCNTR,NMTXT,NMMathClass[PT]SZE,NMTXTCLR);

This sketch tells us which parameters we need to specify. The labels are chosen to be as short as possible, not conflict with reserved words, and stil l communicate enough of their function when read in context. The reader can undoubtedly improve on many of them. We need:

NMARTL (name arrow tail)

NMARHD (name arrow head)

NMARSCLFCT (name arrow scale factor)

NMARCLR (name arrow color)

We have elected to "hardwire" the fact that the arrow has a single head into the code, hence the `SH` enrty

NMCNTR (center of the name text)

NMTXT ( name text)

NMMathClass[PT]SZE (name point size)

NMTXTCLR (name text color)

We decide that we want the arrow to be horizontal and about the level of the shoulders.

A reasonable first approximation for the length of the arrow is the diameter of the head.

The scale factor .05 is usually a good starting point.

We arbitrarily make the arrow orange

We begin by placing the text at the tail of the arrow

The minimal text, we are given is "Joe"

We choose turquoise for the text color

Twenty point type is usually a good first approximation

These then are the parameter declarations we will add (we will of course have to tune with offsets)

> #name arrow and text parameters

> NMARHD:=SHLDR: #arrow head at shoulder

> NMARTL:=SHLDR+[2*HDRDS,0]: # arrow length = head diameter

> NMARSCLFCT:=.05: #.05 scaling factor to start

> NMARCLR:=orange: #arrow color

> NMCNTR:=SHLDR+[2*HDRDS,0]: # text starts at arrow tail

> NMTXT:="Joe":

> NMPTSZE:=20: #start with 20 pt text

> NMTXTCLR:=turquoise: #text color

And we add this to the component constructions

> HSNAME:=MathClass[ARRW](NMARTL,NMARHD,NMARCLR, `SH`, NMARSCLFCT),MathClass[PT](NMCNTR,NMTXT,NMPTSZE,NMTXTCLR):

And we add HSNAME to the plots[display] command in the "assembly" instructions. The result to this point is below. Now its time to add offsets for the arrow and text.

[Maple Plot]

intermediate code for stickman with arrow

> #name arrow and text parameters

> NMARHD:=SHLDR: #arrow head at shoulder

> NMARTL:=SHLDR+[2*HDRDS,0]: # arrow length = head diameter

> NMARSCLFCT:=.05: #.05 scaling factor to start

> NMARCLR:=orange: #arrow color

> NMCNTR:=SHLDR+[2*HDRDS,0]: # text starts at arrow tail

> NMTXT:="Joe":

> PTSZE:=20: #start with 20 pt text

> NMTXTCLR:=turquoise: #text color

>
#Face parameters

> HDCNTR:=[0,4.5]:# head center

> HDRDS:=.5:# head radius

> HDCLR:=blue: #head color

>
#eyes

> LEYCNTR:=[-.2,4.7]: # left eye center

> REYCNTR:=[.2,4.7]:# Right eye center

> EYCLR:=red:# eye color

> EYRDS:=.1: #Eye radius

>
#smile

> SMLCNTR:=[0,4.7]: #smile center

> SMLRDS:=.4: #smile radius

> SMLANGL1:=5*Pi/4:

> SMLANGL2:=7*Pi/4:

> SMLCLR:=green:# smile color

>
#body parameters

> BDYTP:=[0,4]: #body top

> BDYBDM:=[0,1]: #body bottom

> BDYCLR:=magenta: #body color

> #arms

> LHND:=[-2,3]: #left hand

> RHND:=[2,3]: #right hand

> SHLDR:=[0,3.5]:#shoulder(s)

> ARMCLR:=blue: #arm color

>
#legs

> LFT:=[-1,0]: #left foot

> RFT:=[1,0]: #right foot

> LGCLR:=red: # foor color

>
#construction of body components

> FACE:= MathClass[PC](HDCNTR,HDRDS,3,1,HDCLR):

> EYES:=MathClass[PC](LEYCNTR,EYRDS,3,1,EYCLR),MathClass[PC](REYCNTR,EYRDS,3,1,EYCLR):

> SML:=MathClass[PA](SMLCNTR,SMLRDS,SMLANGL1,SMLANGL2,3,1,SMLCLR):

> BDY:=MathClass[DL](BDYTP,BDYBDM,3,1,BDYCLR):

> ARMS:=MathClass[DL](LHND,SHLDR,3,1,ARMCLR),MathClass[DL](RHND,SHLDR,3,1,ARMCLR):

> LGS:=MathClass[DL](LFT,BDYBDM,3,1,LGCLR),MathClass[DL](RFT,BDYBDM,3,1,LGCLR):

> HSNAME:=MathClass[ARRW](NMARTL,NMARHD,NMARCLR, `SH`, NMARSCLFCT),MathClass[PT](NMCNTR,NMTXT,PTSZE,NMTXTCLR):
#assemble figure

> STICKMAN:=plots[display]([HSNAME,LGS,ARMS,BDY,SML,EYES,FACE],scaling=constrained,axes=none):

> STICKMAN;

[Maple Plot]

By inspection is appears that an offset of [1,0] for the arrow and [1.5,0] for the text will be about right The text color is a bit pale so we replace it with "navy" and the arrow is a bit thin so we up the scale factor to .07.

code for stickman with arrow

> #name arrow and text parameters

> ARROFFST:=[1,0]:#shift arrow 1 to right
TXTOFFST:=[1.5,0]:#shift text 1.5 to right

> NMARHD:=SHLDR+ARROFFST: #arrow head at shoulder

> NMARTL:=SHLDR+[2*HDRDS,0]+ARROFFST: # arrow length = head diameter

> NMARSCLFCT:=.07: #.05 scaling factor changed to .07

> NMARCLR:=orange: #arrow color

> NMCNTR:=SHLDR+[2*HDRDS,0]+TXTOFFST: # text starts at arrow tail

> NMTXT:="Joe":

> PTSZE:=20: #start with 20 pt text

> NMTXTCLR:=navy: #text color

>
#Face parameters

> HDCNTR:=[0,4.5]:# head center

> HDRDS:=.5:# head radius

> HDCLR:=blue: #head color

>
#eyes

> LEYCNTR:=[-.2,4.7]: # left eye center

> REYCNTR:=[.2,4.7]:# Right eye center

> EYCLR:=red:# eye color

> EYRDS:=.1: #Eye radius

>
#smile

> SMLCNTR:=[0,4.7]: #smile center

> SMLRDS:=.4: #smile radius

> SMLANGL1:=5*Pi/4:

> SMLANGL2:=7*Pi/4:

> SMLCLR:=green:# smile color

>
#body parameters

> BDYTP:=[0,4]: #body top

> BDYBDM:=[0,1]: #body bottom

> BDYCLR:=magenta: #body color

> #arms

> LHND:=[-2,3]: #left hand

> RHND:=[2,3]: #right hand

> SHLDR:=[0,3.5]:#shoulder(s)

> ARMCLR:=blue: #arm color

>
#legs

> LFT:=[-1,0]: #left foot

> RFT:=[1,0]: #right foot

> LGCLR:=red: # foor color

>
#construction of body components

> FACE:= MathClass[PC](HDCNTR,HDRDS,3,1,HDCLR):

> EYES:=MathClass[PC](LEYCNTR,EYRDS,3,1,EYCLR),MathClass[PC](REYCNTR,EYRDS,3,1,EYCLR):

> SML:=MathClass[PA](SMLCNTR,SMLRDS,SMLANGL1,SMLANGL2,3,1,SMLCLR):

> BDY:=MathClass[DL](BDYTP,BDYBDM,3,1,BDYCLR):

> ARMS:=MathClass[DL](LHND,SHLDR,3,1,ARMCLR),MathClass[DL](RHND,SHLDR,3,1,ARMCLR):

> LGS:=MathClass[DL](LFT,BDYBDM,3,1,LGCLR),MathClass[DL](RFT,BDYBDM,3,1,LGCLR):

> HSNAME:=MathClass[ARRW](NMARTL,NMARHD,NMARCLR, `SH`, NMARSCLFCT),MathClass[PT](NMCNTR,NMTXT,PTSZE,NMTXTCLR):
#assemble figure

> STICKMAN:=plots[display]([HSNAME,LGS,ARMS,BDY,SML,EYES,FACE],scaling=constrained,axes=none):

> STICKMAN;

[Maple Plot]

Example: Add a double arrow to the stickman indicating that the top of his head is six feet above the foor.

Solution: The diagram below meets the requirements. It can obviously be improved. We will make some improvements in the following exercises

[Maple Plot]

The top of the stickman's head is his head radius plus the y-coordnate of the center of his head above the x-axis. This is HDRDS+HDCNTR[2]. His right hand is at RHND and we want the arrow a little to the right of that - the amount will be an offset we choose later. So we take:

HTARHD:=[ RHND[1], HDRDS+HDCNTR[2] ]: (height arrow head)

HTARTL:=[ RHND[1], 0 ]: (height arrow tail)

We need a color for the arrow

HTARCLR:=gold:

We need a scaling factor for the arrow - we usually start with .05

HTARCLRFCT:=.05:

We will place the text at the midpoint of the arrow so:

HTTXTCNTR:=1/2*(HTARHD+HTARTL):

We are given the text

HTTXT:="Six Feet":

Finally, we need a font size and color for the text

HTMathClass[PT]SZE:=20:
HTTXTCLR:=green:

Then all we need to do is construct the component

HSHGHT:=MathClass[ARRW](HTARTL,HTARHD,HTARCLR, `DH`, HTARSCLFCT),MathClass[PT](HTTXTCNTR,HTTXT,HTMathClass[PT]SZE,HTTXTCLR):

Finally we will need to add HSHGT to the plots[display] assembly instructions.

Here is the intermediate result:

[Maple Plot]

code for stickman with two arrows (intermediate)

> # height arrow and text

> HTARHD:=[ RHND[1], HDRDS+HDCNTR[2] ]:

> HTARTL:=[ RHND[1], 0 ]:

> HTARCLR:=gold:

> HTARCLRFCT:=.05:

> HTTXTCNTR:=1/2*(HTARHD+HTARTL):

> HTTXT:="Six Feet":

> HTPTSZE:=20:

> HTTXTCLR:=green:

>

> #name arrow and text parameters

> ARROFFST:=[1,0]:#shift arrow 1 to right
TXTOFFST:=[1.5,0]:#shift text 1.5 to right

> NMARHD:=SHLDR+ARROFFST: #arrow head at shoulder

> NMARTL:=SHLDR+[2*HDRDS,0]+ARROFFST: # arrow length = head diameter

> NMARSCLFCT:=.07: #.05 scaling factor changed to .07

> NMARCLR:=orange: #arrow color

> NMCNTR:=SHLDR+[2*HDRDS,0]+TXTOFFST: # text starts at arrow tail

> NMTXT:="Joe":

> NMPTSZE:=20: #start with 20 pt text

> NMTXTCLR:=navy: #text color

>
#Face parameters

> HDCNTR:=[0,4.5]:# head center

> HDRDS:=.5:# head radius

> HDCLR:=blue: #head color

>
#eyes

> LEYCNTR:=[-.2,4.7]: # left eye center

> REYCNTR:=[.2,4.7]:# Right eye center

> EYCLR:=red:# eye color

> EYRDS:=.1: #Eye radius

>
#smile

> SMLCNTR:=[0,4.7]: #smile center

> SMLRDS:=.4: #smile radius

> SMLANGL1:=5*Pi/4:

> SMLANGL2:=7*Pi/4:

> SMLCLR:=green:# smile color

>
#body parameters

> BDYTP:=[0,4]: #body top

> BDYBDM:=[0,1]: #body bottom

> BDYCLR:=magenta: #body color

> #arms

> LHND:=[-2,3]: #left hand

> RHND:=[2,3]: #right hand

> SHLDR:=[0,3.5]:#shoulder(s)

> ARMCLR:=blue: #arm color

>
#legs

> LFT:=[-1,0]: #left foot

> RFT:=[1,0]: #right foot

> LGCLR:=red: # foor color

>
#construction of body components

> FACE:= MathClass[PC](HDCNTR,HDRDS,3,1,HDCLR):

> EYES:=MathClass[PC](LEYCNTR,EYRDS,3,1,EYCLR),MathClass[PC](REYCNTR,EYRDS,3,1,EYCLR):

> SML:=MathClass[PA](SMLCNTR,SMLRDS,SMLANGL1,SMLANGL2,3,1,SMLCLR):

> BDY:=MathClass[DL](BDYTP,BDYBDM,3,1,BDYCLR):

> ARMS:=MathClass[DL](LHND,SHLDR,3,1,ARMCLR),MathClass[DL](RHND,SHLDR,3,1,ARMCLR):

> LGS:=MathClass[DL](LFT,BDYBDM,3,1,LGCLR),MathClass[DL](RFT,BDYBDM,3,1,LGCLR):

> HSNAME:=MathClass[ARRW](NMARTL,NMARHD,NMARCLR, `SH`, NMARSCLFCT),MathClass[PT](NMCNTR,NMTXT,NMPTSZE,NMTXTCLR):
#assemble figure

> HSHGHT:=MathClass[ARRW](HTARTL,HTARHD,HTARCLR,`DH`, HTARCLRFCT),MathClass[PT](HTTXTCNTR,HTTXT,HTPTSZE,HTTXTCLR):

> STICKMAN:=plots[display]([HSHGHT,HSNAME,LGS,ARMS,BDY,SML,EYES,FACE],scaling=constrained):

> STICKMAN;

[Maple Plot]

>

>

We observe that the arrow needs to be shifted to the right. From the diagram a shift of [2,0] should work.
The arrow is somewhat thick we reduce the scaling factor

[Maple Plot]

code for stickman with two arrows

> # height arrow and text

> HTAROFFSET:=[2,0]:

> HTARHD:=[ RHND[1], HDRDS+HDCNTR[2] ] +HTAROFFSET:

> HTARTL:=[ RHND[1], 0 ] +HTAROFFSET :

> HTARCLR:=gold:

> HTARCLRFCT:=.03: #reduced from .05

> HTTXTCNTR:=1/2*(HTARHD+HTARTL):

> HTTXT:="Six Feet":

> HTPTSZE:=20:

> HTTXTCLR:=green:

>

> #name arrow and text parameters

> ARROFFST:=[1,0]:#shift arrow 1 to right
TXTOFFST:=[1.5,0]:#shift text 1.5 to right

> NMARHD:=SHLDR+ARROFFST: #arrow head at shoulder

> NMARTL:=SHLDR+[2*HDRDS,0]+ARROFFST: # arrow length = head diameter

> NMARSCLFCT:=.07: #.05 scaling factor changed to .07

> NMARCLR:=orange: #arrow color

> NMCNTR:=SHLDR+[2*HDRDS,0]+TXTOFFST: # text starts at arrow tail

> NMTXT:="Joe":

> NMPTSZE:=20: #start with 20 pt text

> NMTXTCLR:=navy: #text color

>
#Face parameters

> HDCNTR:=[0,4.5]:# head center

> HDRDS:=.5:# head radius

> HDCLR:=blue: #head color

>
#eyes

> LEYCNTR:=[-.2,4.7]: # left eye center

> REYCNTR:=[.2,4.7]:# Right eye center

> EYCLR:=red:# eye color

> EYRDS:=.1: #Eye radius

>
#smile

> SMLCNTR:=[0,4.7]: #smile center

> SMLRDS:=.4: #smile radius

> SMLANGL1:=5*Pi/4:

> SMLANGL2:=7*Pi/4:

> SMLCLR:=green:# smile color

>
#body parameters

> BDYTP:=[0,4]: #body top

> BDYBDM:=[0,1]: #body bottom

> BDYCLR:=magenta: #body color

> #arms

> LHND:=[-2,3]: #left hand

> RHND:=[2,3]: #right hand

> SHLDR:=[0,3.5]:#shoulder(s)

> ARMCLR:=blue: #arm color

>
#legs

> LFT:=[-1,0]: #left foot

> RFT:=[1,0]: #right foot

> LGCLR:=red: # foor color

>
#construction of body components

> FACE:= MathClass[PC](HDCNTR,HDRDS,3,1,HDCLR):

> EYES:=MathClass[PC](LEYCNTR,EYRDS,3,1,EYCLR),MathClass[PC](REYCNTR,EYRDS,3,1,EYCLR):

> SML:=MathClass[PA](SMLCNTR,SMLRDS,SMLANGL1,SMLANGL2,3,1,SMLCLR):

> BDY:=MathClass[DL](BDYTP,BDYBDM,3,1,BDYCLR):

> ARMS:=MathClass[DL](LHND,SHLDR,3,1,ARMCLR),MathClass[DL](RHND,SHLDR,3,1,ARMCLR):

> LGS:=MathClass[DL](LFT,BDYBDM,3,1,LGCLR),MathClass[DL](RFT,BDYBDM,3,1,LGCLR):

> HSNAME:=MathClass[ARRW](NMARTL,NMARHD,NMARCLR, `SH`, NMARSCLFCT),MathClass[PT](NMCNTR,NMTXT,NMPTSZE,NMTXTCLR):
#assemble figure

> HSHGHT:=MathClass[ARRW](HTARTL,HTARHD,HTARCLR,`DH`, HTARCLRFCT),MathClass[PT](HTTXTCNTR,HTTXT,HTPTSZE,HTTXTCLR):

> STICKMAN:=plots[display]([HSHGHT,HSNAME,LGS,ARMS,BDY,SML,EYES,FACE],scaling=constrained,axes=none):

> STICKMAN;

[Maple Plot]

>

>

Exercises:

Exercise 1: Add a floor or ground for the stickman to stand on. Make the vertical arrow touch the ground.

Exercise 2: Move the arrow pointing to the stickman to the left and raise it to the level of the stickman's head.

Exercise 3: Take the original stickman figure without the added arrows and text and add a right elbow bent up with the right hand "waving".

Exercise 4: Change the stickman to a stickwoman.

Exercise 5: Adapt the stickman's head and make a yellow "happy face", placing the text "Have a Nice Day" beneath it.

Adding Colored figures: polygonplot and plottools

One of the exercises in the previous section was to make a "stickwoman". Over variant on that characture is the following:

[Maple Plot]

code for woman

>
#Face parameters

> HDCNTR:=[0,4.5]:# head center

> HDRDS:=.5:# head radius

> HDCLR:=blue: #head color

>
#eyes

> LEYCNTR:=[-.2,4.7]: # left eye center

> REYCNTR:=[.2,4.7]:# Right eye center

> EYCLR:=red:# eye color

> EYRDS:=.1: #Eye radius

>
#smile

> SMLCNTR:=[0,4.7]: #smile center

> SMLRDS:=.4: #smile radius

> SMLANGL1:=5*Pi/4:

> SMLANGL2:=7*Pi/4:

> SMLCLR:=green:# smile color

>
#body parameters

> #BDYTP:=[0,4]: #body top

> #BDYBDM:=[0,1]: #body bottom

> #BDYCLR:=magenta: #body color

#neck

> NCKTOP:=[0,4]:

> NCKBDM:=[0,3.5]:

> #stickwoman dress

>

> DRSTOP:=[0,3.5]: #top of dress for stickwoman

> LDRSBDM:=[-1,1]:
RDRSBDM:=[1,1]:

>

>

> #arms

> LHND:=[-2,3]: #left hand

> RHND:=[2,3]: #right hand

> SHLDR:=[0,3.5]:#shoulder(s)

> ARMCLR:=blue: #arm color

>
#legs

> LFTLEGTOP:=(3/4*LDRSBDM+1/4*RDRSBDM):

>

> RTLEGTOP:=(3/4*RDRSBDM+1/4*LDRSBDM):

> LFFT:=[LFTLEGTOP[1],0]: #left foot

> RTFT:=[RTLEGTOP[1],0]:#right foot

>

> LGCLR:=red: # foor color

>
#construction of body components

> FACE:= MathClass[PC](HDCNTR,HDRDS,3,1,HDCLR):

> EYES:=MathClass[PC](LEYCNTR,EYRDS,3,1,EYCLR),MathClass[PC](REYCNTR,EYRDS,3,1,EYCLR):

> SML:=MathClass[PA](SMLCNTR,SMLRDS,SMLANGL1,SMLANGL2,3,1,SMLCLR):

> #BDY:=MathClass[DL](BDYTP,BDYBDM,3,1,BDYCLR):

> DRS:=plots[polygonplot]([DRSTOP,LDRSBDM,RDRSBDM],color=yellow):

> ARMS:=MathClass[DL](LHND,3/4*DRSTOP+1/4*LDRSBDM,3,1,ARMCLR),MathClass[DL](RHND,3/4*DRSTOP+1/4*RDRSBDM,3,1,ARMCLR):

> LGS:=MathClass[DL](LFTLEGTOP,LFFT,3,1,LGCLR),MathClass[DL](RTLEGTOP,RTFT,3,1,LGCLR):

> NCK:=MathClass[DL](NCKTOP,NCKBDM,3,1,blue):
#assemble figure

> STICKMAN:=plots[display]([NCK,LGS,ARMS,DRS,SML,EYES,FACE],scaling=constrained,axes=none):

> STICKMAN;

[Maple Plot]

>

Obviously "she" can be improved but first we want to discuss her "dress" which is a colored triangle - or more generally a colored polygon.

Adding Titles to Diagrams

Two of the options to the plots[display] command are title and titlefont. With them we can give diagrams titles in font sizes of our chosing. For instance we can add the title "I am SmileyFace" to the smileyface diagram by editing the plots[display] command to

SMFACE:=plots[display]([EYS,SML,DSK],scaling=constrained,axes=none,title=`I am SmileyFace`,titlefont=[HELVETICA,OBLIQUE,20]):

[Maple Plot]

Unfortunately it is not yet possible to add nicely formatted mathematics to a title.

smileyfacewithtitle

> #face

> FCECNTR:=[0,0]:# face center

> FCERDS:=1:#face radius

> LEYECNTR:=FCECNTR+FCERDS*[-.5,.25]:#Left eye center

> REYECNTR:=FCECNTR+FCERDS*[+.5,.25]:#right eye center

> EYERDS:=.15*FCERDS:#eye radius

> FCECLR:=yellow:# face color

> EYECLR:=black:#eye color

> #smile (stolen from stickman)

> SMLCNTR:=FCECNTR+FCERDS*[0,.25]: #smile center

> SMLRDS:=.9*FCERDS: #smile radius

> SMLANGL1:=9*Pi/8:

> SMLANGL2:=15*Pi/8:

> SMLCLR:=black:# smile color

> #components

> DSK:=plottools[disk](FCECNTR,FCERDS,color=FCECLR):

> EYS:=MathClass[PC](REYECNTR,EYERDS,3,1,EYECLR),MathClass[PC](LEYECNTR,EYERDS,3,1,EYECLR):

> SML:=MathClass[PA](SMLCNTR,SMLRDS,SMLANGL1,SMLANGL2,3,1,SMLCLR):

> #assembly

> #SMFACE:=plots[display]([EYS,SML,DSK],scaling=constrained,axes=none):
SMFACE:=plots[display]([EYS,SML,DSK],scaling=constrained,axes=none,title=`I am SmileyFace`,titlefont=[HELVETICA,OBLIQUE,18]):

> SMFACE;

[Maple Plot]