web view[100] 002 revised on 2012.12.03. cemmath. the simple is the best. chapter 2 plot. 2-1 what...

60
[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com [100] 002 revised on 2012.12.03 cemmath The Simple is the Best Chapter 2 Plot 2-1 What is the Concept of Umbrella 2-2 Multiple Curves and Built-In Geometries 2-3 Special Plots and Parameterized Curves in 2D 2-4 Treatment of Data 2-5 Manipulating Curves 2-6 Curves in 3D 2-7 Surfaces in 3D 2-8 Revolution in 3D 2-9 Popped and Filled Surfaces in 3D 2-10 Summary of Syntax 2-11 References The introduction of Cemmath begins with explaining a new and amazing concept of Umbrella. In this chapter, we explain the elements and characteristics of Umbrella ‘plot’. Later, we will describe several different Umbrellas such as ‘int’, ‘ode’, ‘bvp’, ‘pdeetc. Section 2-1 What is the Concept of Umbrella 1

Upload: vominh

Post on 30-Jan-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

[100] 002 revised on 2012.12.03 cemmath

The Simple is the Best

Chapter 2 Plot

2-1 What is the Concept of Umbrella2-2 Multiple Curves and Built-In Geometries 2-3 Special Plots and Parameterized Curves in 2D2-4 Treatment of Data2-5 Manipulating Curves 2-6 Curves in 3D 2-7 Surfaces in 3D2-8 Revolution in 3D2-9 Popped and Filled Surfaces in 3D2-10 Summary of Syntax 2-11 References

The introduction of Cemmath begins with explaining a new and amazing concept of Umbrella. In this chapter, we explain the elements and characteristics of Umbrella ‘plot’. Later, we will describe several different Umbrellas such as ‘int’, ‘ode’, ‘bvp’, ‘pde’ etc.

Section 2-1 What is the Concept of Umbrella

Since the concept of Umbrella innovated in Cemmath is originated from an attempt to plot curves efficiently and in a systematic way, out first step is to analyze the plot process in the two-dimensional space.

■ Definition of Grid Span. Suppose that we need to draw a curve y=x2 over an interval of a≤ x≤ b where a=0 , b=3. For the sake of brevity in explanation, let us take only n=4 nodes such that x=[0,1,2,3]. This will be called the grid span which has four components

1

Page 2: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

left-end, aright-end, bgrid size, ngrid control, g

Thus a general definition of the grid span is

.x[n,g](a,b)

where the leading dot, i.e. ‘.’, is intentional. The meanings of the left-end, the right-end as well as the grid size are straightforward. However, the grid control g needs to be further discussed here. For a special case of g=1, the nodes in the x-coordinate are distributed linearly as

x i=a+ (b−a ) (i−1 )n−1

,i=1,2,3 , …, n

In general, the grid control distributes the nodes such that

d x i=gd x i−1 , d xi=xi−xi−1

It is evident that the grid control g represents a ratio between two successive spacings. Examples for a few grid controls are

.x[5,2] (0,15) makes x = [0,1,3,7,15] where dx = [1,2,4,8]

.x[5,0.5] (0,15) makes x = [0,8,12,14,15] where dx = [8,4,2,1]

.x[7,-2] (1,15) makes x = [1,2,4,8,12,14,15] where dx = [1,2,4,4,2,1]

.x[6,-0.5](1,14) makes x = [1,5,7,8,10,14] where dx = [4,2,1,2,4]

In other words, when the grid control takes a negative value, the grid spacing is symmetric. For practical use, default values, n=51, g=1, are used if not specified explicitly.

■ Elements of Umbrella. An Umbrella is normally composed of three parts: Hub, Stem and Spoke.

2

Page 3: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

(1) The Hub begins with a dot ‘.’ and describes a grid span. The identifier after ‘.’ does not represent a member function of a class in C++, but designates an independent variable used in the forthcoming mathematical expression within the Stem. The Hub defined as

.x[n,g](a,b)

is indeed the same as the grid span mentioned above.

(2) The Stem is enclosed by ‘( )’ and contains mathematical functions of interest. The variable defined in the Hub is regarded as the independent variable in the Stem. Other pre-defined variables are used as if they were local variables. For example, when one writes

#> a = 2; plot .x[21,1](-2,2) ( x*x-a );

the variable ‘a’ can participate in the definition of the Stem without any further declaration, while the Hub variable ‘x’ is internal to the Umbrella. In addition, the following Cemmath command

#> a = 2; x = 3; plot .x[21,1](-2,2) ( x*x-a ); y = x+4;

yields y = 7. The internal variable x for the Umbrella ‘plot’ has nothing to do with the external variable x outside of the Umbrella even if their names are the same.

(3) The Spoke begins with a dot ‘.’ and manipulates additional operations on the figure. It is apt to consider the Spoke as something similar to the member function of a class in C++. This is true in one sense, but is not in another sense. The behaviors of the Spoke and the member function of C++ are notably different.

In order to understand the roles of the above three elements, let us start with a simple Cemmath command

#> plot // name of Umbrella .x[21,1](-2, 2) // Hub ( x*x ) // Stem .flip ; // Spoke

3

Page 4: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

which is the same as

#> plot .x[21,1](-2,2) ( x*x ) .flip ;

since the style of C-language is adopted in Cemmath. Figure 1 is the result shown in the screen. Note that the bare curve without any decoration is plotted.

Now, let us discuss what kinds of processes have been performed internally. First, Hub (i.e. the grid span as was mentioned earlier) prepares 21 node points over an interval of −2≤ x ≤2 with a uniform spacing (g=1). Next, Stem evaluates y=x2 at all the corresponding points. Then, Spoke ‘flip’ transforms the so-obtained data in a manner ( X , Y )=(x , y ) which represents a symmetry with respect to a line y=x . This is our first success to plot a curve with the aid of Umbrella ‘plot’. The power of Spokes inherits from a variety of useful operations.

In most software, plot command (or similar ones) performs a single mission of plotting figures. On the contrary, Umbrella ‘plot’ in Cemmath utilizes a series of Spokes to fulfill user’s diverse purposes.

Figure 1 Graph of by use of Umbrella ‘plot’

■ Spokes for 2D curves. In the following, summarized are some of the Spokes applicable for 2D curves. Note that (x,y) denotes the data point in the last Spoke, and (X,Y) the data point in the current Spoke. Many of the Spokes listed below can be applied for 3D curves and 3D surfaces, too.

4

2x y

Page 5: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

plot.now ; plot; // plot immediately plot+.hold ; hold the current plot for overwriting plot .hold ; plot new and hold

.flip (X,Y) = (y,x) symmetry about line y = x

.xmove(a) (X,Y) = (x+a,y) translate in x-direction by a

.ymove(b) (X,Y) = (x,y+b) translate in y-direction by b

.move(a,b) (X,Y) = (x+a,y+b) translate by a vector (a,b)

.xscale(sx,a=0) (X,Y) = (a+sx*(x-a),y) elongate in x-dir about line x=a

.yscale(sy,b=0) (X,Y) = (x,b+sy*(y-b)) elongate in y-dir about line y=b

.xlog (X,Y) = (log10(x), y)

.ylog (X,Y) = (x, log10(y))

.xylog/loglog (X,Y) = (log10(x), log10(y))

.xsym(a=0) (X,Y) = (2*a-x, y) symmetry about line x=a

.ysym(b=0) (X,Y) = (x, 2*b-y) symmetry about line y=b

.osym @(xo,yo) (X,Y) = (2*xo-x, 2*yo-y) symmetry about point (xo,yo)

.scale(sx,sy) @(xo,yo) (X,Y) = (xo+sx*(x-xo),yo+sy*(y-yo))

.zrot(t) @(xo,yo) rotate counterclockwise about (xo,yo)

.lsym(a,b,c) symmetry with respect to line ax+by+c = 0

.lstep lower-step function

.ustep upper-step function

.xstem stem with respect to the x-coordinate

.ystem stem with respect to the y-coordinate

.xystem stem with respect to the x- and y-coordinates

.stem stem with circle

.link connect piecewise curve to the last curve

.merge make all curves to be a single curve

.movelink connect piecewise curves to the last ending point

.copy[n] (dx,dy) duplicate a total of n curves and move by (dx,dy)

.copylink[n] (dx,dy) copy[n](dx,dy) and make all curves to be a single curve

.xmean(xm) extracts a mean value of x

.ymean(ym) extracts a mean value of y

.togo(A) extracts matrix A for vertex data of each curve

.allout(A) extracts matrix A for all the vertex data

.info print out information on curves and vertex

and a few more will be discussed later

Of course, all the Spokes attached to Stem are processed in order of appearance. Nevertheless, it is worthy of emphasis that some Spokes are not commutative. For example ‘.xsym.flip’ is not the same as ‘.flip.xsym’. Figure 2 shows a few examples of using Spokes by the following commands.

5

Page 6: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

#> plot .x[21](0,5) ( exp(x/2) ) ; #> plot .x[21](0,5) ( exp(x/2) ) .ustep ;#> plot .x[21](0,5) ( exp(x/2) ) .ystem ;#> plot .x[21](0,5) ( exp(x/2) ) .xstem ; #> plot .x[21](0,5) ( exp(x/2) ) .xystem ;

Figure 2 Examples of various Spokes for Umbrella ‘plot’

It is also possible to plot Figure 2 by using pre-defined matrices

#> X = (0,5).span(21);#> F = exp(X/2);#> plot(X,F) ; #> plot(X,F) .ustep ; #> plot(X,F) .ystem ; #> plot(X,F) .xstem ; #> plot(X,F) .xystem ;

■ Nature of Spoke. The Spoke has a nature analogous to the member functions of a class in C++, and can be omitted if not necessary. However, there exist several notable differences between the Spoke and the member function.

First, Spoke can treat various types of arguments. Second, the internal variable defined in Hub (e.g. ‘x’) can be explicitly used in some Spokes. Third, Spoke can handle vector operators (dot product and cross product). These will

6

Page 7: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

be discussed in detail later.

Section 2-2 Multiple Curves and Built-In Geometries

■ Multiple Curves. When multiple curves over the same grid spacing need to be plotted, Stem can include multiple expressions. In Cemmath, it is very clear to understand overwriting of curves. As an analogy to ++ operator in C-language, ‘plot+’ is innovated to fulfill this purpose.

The following example illustrates the case of both multiple curves and overwriting. It is clear that Figure 3 shows the desired performance of Spokes ‘lstep’ (lower step) and ‘ustep’ (upper step).

#> plot .x[21](0,2*pi) ( sin(x),cos(x) ); // Figure 3#> plot+.x[21](0,2*pi) ( sin(x),cos(x) ).ustep; // upper step #> plot+.x[21](0,2*pi) ( sin(x),cos(x) ).lstep; // lower step

Figure 3 Examples of ustep and lstep

When the current curve is used to generate multiple curves by duplication, Spokes ‘copy’ and ‘copylink’ are very useful. Periodic functions can be very easily drawn by using these Spokes. A difference between ‘copy’ and ‘copylink’ is that ‘copy’ generates curves separately, while ‘copylink’ connects all the curves.

#> plot.x[11](0,pi) (sin(x)).copy [5](pi/2,0.5); // Figure 4 #> plot.x[11](0,pi) (sin(x)).copylink[5](pi/2,0.5); // Figure 5

7

Page 8: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

The above commands clearly explain the difference between ‘copy’ and ‘copylink’, as shown in Figures 4 and 5. The total number of curves duplicated by ‘copy’ and ‘copylink’ are designated by ‘[ ]’ which resembles the definition of array.

Figure 4 Example of copy Figure 5 Example of copylink

■ Built-In Geometries. Geometries most frequently encountered in 2D would be point, line, circle, square, rectangle, trapezoid, triangle, etc. In this regard, Cemmath supports built-in geometries replacing Stem by well-known names. An aftermath of omitting Stem is the ambiguity associated with preparing nodes. This problem can be resolved by introducing a pair of brackets ‘[ ]’ inside which grid span can be implemented, whenever necessary. Listed below are a few numbers of built-in geometries.

.triangle (a,b,c )

.square (a )

.star (r )

.rectangle (a,b )

.parallel (a,b, theta )

.trapezoid (a,b, height)

8

Page 9: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

.circle [nt=51,gt=1] (radius)

.polygon [nvert,gt=1] (radius) // nvert >= 3

.ellipse [nt=51,gt=1] (a,b )

.point (xo,yo)

.vector [scale=1,headscale=1,headangle=30] (a,b)

.line (x1,y1, x2,y2)

Figure 6 shows the results of

#> plot .circle(1); // .circle [nt=51,gt=1] (radius) #> plot+.ellipse(2,0.5); // .ellipse [nt=51,gt=1] (a,b ) #> plot+.polygon[3](1); // .polygon [nvert,gt=1] (radius) #> plot+.triangle(2,2,2); // .triangle (a,b,c ) #> plot+.square(2); // .square (a )

There is a slight difference between triangle and polygon[3]. Spoke ‘polygon’ always centers geometries at the origin, and needs input as a radius. But Spoke ‘triangle’ has the origin as a starting point, and the side length is given as input.

Figure 6 Built-in geometries in 2D

Further shown in Figure 7 are the results of

#> plot .star(0.1); // .star (radius) #> plot+.rectangle(2,3); // .rectangle(a,b)

9

Page 10: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

#> plot+.parallel(4,3, pi/3); // .parallel (a,b, theta) #> plot+.trapezoid(3,2, 2); // .trapezoid(a,b, height)

Figure 7 Built-in geometries in 2D

Section 2-3 Special Plots and Parameterized Curves in 2D

■ Vector Plot. The built-in geometry ‘vector’ can be utilized to illustrate several important features of phenomena. The definition of Spoke ‘vector’ was

.vector [scale=1, headscale=1, headangle=30] (a,b)

The element scale is used to control the vector length, while the headscale controls the appearance of arrowhead. The default size of arrowhead (i.e. headscale = 1) is 1/20 of the vector length. If headscale = 0, an arrowhead will not be shown. Furthermore, a negative value of scale corresponds to a constant length of vectors with an arrowhead of constant size (-scale/20*headscale).

Users should not be confused with Spoke ‘line’ and ‘vector’. Spoke ‘line’ connects two points listed as arguments, whereas Spoke ‘vector’ depicts a direction vector located at a given origin. As a matter of fact, the following two commands are the same

plot .line(a,b, c,d) and plot .vector[1,0](c-a,d-b) .move(a,b)

10

Page 11: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

A practically important example would be tangential velocity vectors along a circle. It is not difficult to understand that the result of the following corresponds to Figure 8.

#> .hold; // create a new plot window and hold on for overwriting plot.circle(1); for.n(0,19) { t = n*pi/10;; x = cos(t);; y = sin(t);; plot.star(0.04) .move(x,y); plot.vector(-y,x) .move(x,y); } #> plot;

Figure 8 Tangential velocities along a circle

The phase diagram in Figure 9 arises from a differential equation for a pendulum y ''+sin y=0from which y1

' = y2 , y2' =−sin y1 are defined. The

corresponding Cemmath commands are

#> .hold; for.y1(-5,5.01, 0.5) // for(y1 = -5; y1 < 5.01; y1 += 0.5) for.y2(-3,3.01, 0.5) { // for(y2 = -3; y2 < 3.01; y2 += 0.5) plot.vector[0.3,3] (y2,-sin(y1)) .move(y1,y2); // Figure 9a } plot; #> .hold; for.y1(-5,5.01, 0.5) for.y2(-3,3.01, 0.5) { plot.vector[-0.1,3] (y2,-sin(y1)) .move(y1,y2); // Figure 9b

11

Page 12: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

} plot;

This special plot will be treated later again.

Figure 9 Phase diagram for a pendulum motion

■ Parameterized Curve. One unique case of parameterized curves in plane is the polar curve defined as

x=r cosθ , y=rsin θ

and is implemented in Cemmath with a syntax

plot .t[n=51,g=1](a,b) ( <<opt>>, r(t), ... ) .cyl // 2D curve(s)

In other words, Spoke ‘cyl’ (or ‘polar’) converts the curves from rectangular to polar coordinates. In general, the parameterized curves in plane have a form of

x=x (u ) , y= y (u)

where a ≤ x≤ b. To designate a certain variable to be a parameter, the character ‘@’ is used for convenience. In this regard, the following Cemmath syntax

plot .@u[n=51,g=1](a,b) ( <<opt>>, x(u), y(u) ) // only one curve plot .@u[n=51,g=1](a,b) ( <<opt>>, r(u), t(u) ).cyl // 2D curve

draws a parameterized curve as desired, where the character ‘@’ is employed to represent parameter. If the character ‘@’ is omitted, two curves will appear with u as the horizontal axis.

12

Page 13: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

Some of the curves drawn in Figures 10-12 bear artistic nature, and interested readers are recommended to refer literature cited herein.

#> plot.t[101](0,2*pi) ( cos(t), cos(2*t) ).cyl; // x*x + y*y - x = 0

Figure 10 Polar plot

#> (a,b) = (12,5);; // Epicycloid#> plot .@t[1001](0,10*pi) ( << u = (a/b+1)*t >>, (a+b)*cos(t)-b*cos(u), (a+b)*sin(t)-b*sin(u) );

Figure 11 An epicycloid

13

Page 14: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

#> (a,b) = (501,7); #> (a,b) = (501,7); (rx,ry) = (10,10); (bx,by) = (1,2); (cx,cy) = (9,2); (ex,ey) = (6.5,5.5); // Rose and butterfly

#> .hold;#> plot.t[3001](0,2*pi*a) ( 5*sin(b*t) ).cyl.move(rx,ry); // A rose is a rose ....

#> plot.t[1001](0,10*pi) ( exp(cos(t))-2*cos(4*t)+(sin(t/12))^5 ).cyl .zrot(pi/6).move(bx,by); // butterfly

#> plot.ellipse(12,8).zrot(50*pi/180).move(ex,ey); // inclined ellipse #> plot.circle(2) .move(cx,cy); // necklace of radius 2

#> for(t = 0; t <= 2; t += 0.1) plot.circle[11](0.2) .move(cx+2*cos(pi*t), cy+2*sin(pi*t) );

#> plot;

// P.M. Maurer, A rose is a rose ..., Math. Monthly, 94 (1987), pp. 631-645.// T.H. Fay, A study in step size, April issue, Mathematics Magazine (1997).

Figure 12 Butterfly, rose and necklace within an inclined ellipse

14

Page 15: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

■ Phase Diagram. The phase diagram shown in Figure 9 involved a differential equation written as y ''+sin y=0with y1

' = y2 , y2' =−sin y1. This

can be implemented in a much easier way by introducing Spoke ‘phase’ the syntax of which is

plot .u[n=21,g=1](a,b) .v[n=21,g=1](c(u),d(u)) ( u', v' ) .phase[scale=1,headscale=1,headangle=30]

The result shown in Figure 9 is considered again in Figure 13 by the following commands for two different boundaries

#> plot.y1[15](-5,5).y2[15](-3,3) ( y2,-sin(y1) ).phase[0.3,3]; #> plot.y1[15](-5,5).y2[15](-3*cos(pi/11*y1),3*cos(pi/11*y1)) ( y2,-sin(y1) ).phase[0.3,3];

Figure 13 Phase diagram for a pendulum motion with Spoke ‘phase’

Section 2-4 Treatment of Data

15

Page 16: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

The most powerful aspect of Spoke ‘togo’ is that vertex data can be withdrawn at any stage of Spoke. For example, the following commands #> plot.x[11](-1,1) (1-x*x) .togo(P) // plot a parabola, and get data .zrot(pi/6) .togo (Q) // rotation about z-axis, and get data .lsym(3,2,1) .togo(R); // line symmetry about 3x+2y+1 = 0, and get data #> P; Q; R; // print data points after each Spoke

extract vertex data in matrix form after each Spoke

P = [ -1 0 ] [ -0.8 0.36 ] [ ... ... ] [ 0.8 0.36 ] [ 1 0 ] Q = [ -0.86603 -0.5 ] [ -0.87282 -0.088231 ] [ ... ... ] [ 0.51282 0.71177 ] [ 0.86603 0.5 ]

R = [ 0.33309 0.29941 ] [ -0.044394 0.46405 ] [ ... ... ] [ -1.3158 -0.50731 ] [ -1.2562 -0.91479 ]

These vertex data at each Spoke can be handled by users for other purposes, e.g. saving to the file.

In some cases, all the vertex data in one layout need to be withdrawn. This can be accomplished by Spoke ‘allout’. The following commands

#> plot .square(1) .togo(P); #> plot+ .polygon[3] .togo(Q).allout(R).info; // togo and allout #> P; Q; R;

illustrate the difference between ‘togo’ and ‘allout’ as follows.

16

11 2

Page 17: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

P = [ 0 0 ] [ 1 0 ] [ 1 1 ] [ 0 1 ] [ 0 0 ]

Q = [ 0 1 ] [ -0.86603 -0.5 ] [ 0.86603 -0.5 ] [ 0 1 ]

R = [ 0 0 ] [ 1 0 ] [ 1 1 ] [ 0 1 ] [ 0 0 ] [ 0 1 ] [ -0.86603 -0.5 ] [ 0.86603 -0.5 ] [ 0 1 ]

In addition, Spoke ‘info’ displays the number of disconnected curves and the vertex data in each curve, as well as the total number of vertices, as follows

//==========================================// # of curves = 2// # of vertex = 9// # of points in each curve// 5 4//==========================================

Section 2-5 Manipulating Curves

■ Curve Identification. Representing a curve by a finite number of points may entail the following definition of curves. A curve C i is defined as

C i= \{ ( x j , y j )∨ j=1,2,3 , …,n i \}

and the point at j=1 is denoted by C is (starting point), and the point at j=ni is

17

Page 18: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

denoted by C is (ending point). All other points then lie in between in view of connectivity (not by spatial location).

Connecting two curves C1 and C2 into one curve C3 can be considered as creating a new curve with a new ending point C3e=C2e. The original ending point C1 s in curve C1 and the starting point C2 s in C2 are treated as inner points

in C3 after connection. This concept will be helpful in working with many composite curves generated from different mathematical functions.

■ Geometric Centers. Geometric centers of a curve are defined as

xm=1n∑i=1

n

x i , ym=1n∑i=1

n

y i

However, for a closed curve with C is=Cie, geometric centers are defined as

xm=1

n−1∑i=1

n−1

x i , ym=1

n−1∑i=1

n−1

y i

since the starting and the ending points are identical. In some cases, it is necessary to place curves at its geometric centers, e.g. the results obtained by

#> .hold; plot .t[51](0,2*pi) ( 1+cos(t) ).cyl; plot .star(0.1); for.n(0, 50) { t = n*2*pi/50;; r = 1+cos(t);; plot .polygon[3](0.02).move( r*cos(t),r*sin(t) ); } plot .t(0,2*pi) ( 1+cos(t) ).cyl

.xmean(xm).ymean(ym).move(-xm,-ym).xmean(xm2);#> plot;#> xm; ym; xm2;

xm = 0.500000ym = 0.000000xm2 = 0.000000

18

Page 19: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

are shown in Figure 14. Note that Spoke ‘xmean’ and ‘ymean’ are evaluated at the time of appearance.

Figure 14 Geometric centers

■ Disconnections. Frequently, disconnections may exist in the curve. These disconnections can be removed by using Spoke ‘link’ and ‘merge’. For example, Figure 15 shows two cases of using ‘link’ and ‘merge’. By the use of Spoke ‘link’, a single disconnection at x=2 has been removed as can be seen. The Spoke ‘merge’ makes a single curve by connecting all the curves.

#> .hold; plot .x[2](0,1) (x); plot .x[2](1,2) (x-1); plot .x[2](2,3) (x-2).link; // Figure 15a plot;

#> .hold; plot .x[2](0,1) (x); plot .x[2](1,2) (x-1); plot .x[2](2,3) (x-2).merge; // Figure 15bplot;

19

Page 20: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

Figure 15 Removing disconnection with link and merge

When the Spoke ‘link’ is applied, the subsequent Spoke such as ‘zrot’ then affects the previously defined curve. We can see this behavior by Cemmath command

#> .hold; plot .x[11](0,2) (4-x*x); plot .x(2,4) ( 0.3*x ).zrot(pi/6); // Figure 16a plot;

#> .hold; plot .x[11](0,2) (4-x*x); plot .x(2,4) ( 0.3*x ).link.zrot(pi/6); // Figure 16b plot;

and by the result shown in Figure 16.

Figure 16 The effect of link

A special care should be taken in using Spoke ‘link’ and ‘merge’. Whenever the ending point C ie coincides with the starting point C js of the next

20

Page 21: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

curve, the starting point C js is eliminated and thus the number of points is reduced by one. This is natural as we expect it should be.

In a variety of situations, it is desired to connect many segments one-by-one by placing the ending point C ie at the starting point C js. In doing this, we wish not to worry about creating each segment at the desired location. What we want is to make many curves wherever one feels comfortable (much like curve-making factory) and move them to desired points. This convenient operation can be fulfilled by using Spoke ‘movelink’. Figure 17 illustrates the use of Spoke ‘movelink’ to make a circle with a series of tangent vectors where the corresponding Cemmath commands are

#> .hold; t = pi/10;; plot .point(-0.5,0); for.n(0,19) plot .vector[1,0](cos(n*t),sin(n*t)) .movelink; #> plot;

Note that a use of Spoke ‘point’ just controls a starting point. Without this command, the curve will be shifted by 0.5.

Figure 17 Manipulating segments by movelink

Section 2-6 Curves in 3D

■ Parameterization of 3D curve. The curves in three-dimensional space are typically parameterized in the rectangular, cylindrical and spherical coordinates as

21

Page 22: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

C={( x , y , z )|a ≤u ≤ b , x=x (u ) , y= y (u ) , z=z (u ) \}C={(r , θ , z )|a≤ u ≤ b , r=r (u ) , θ=θ (u ) , z=z (u ) \}

C={(r , φ , θ )|a ≤ u ≤b ,r=r (u ) , φ=φ(u) ,θ=θ (u ) \}

where

cylindrical: x=r cosθ , y=rsin θ

spherical: x=r sin φ cosθ , y=r sin φ sinθ , z=rcos φ

and the corresponding syntax in Cemmath is

plot .@u[n=51,g=1](a,b) ( <<opt>>, x(u),y(u),z(u) ) // 3 functions plot .@u[n=51,g=1](a,b) ( <<opt>>, r(u),t(u),z(u) ) .cyl // 3D curve plot .@u[n=51,g=1](a,b) ( <<opt>>, r(u),p(u),t(u) ) .sph // 3D curve

It should be noted that Stem must have 3 functions. When Stem has 2 functions, a curve in 2D will be plotted, and an error will occur otherwise. A large number of Spokes used in 2D are also applicable to curves in 3D. Several new Spokes are provided to take care of 3D geometries. Among those are

.cyclic (X,Y,Z) = (z,x,y)

.cyclic.cyclic (X,Y,Z) = (y,z,x)

.zlog (X,Y,Z) = (x,y,log10(z))

.zmove(c) (X,Y,Z) = (x,y,z+c)

.zscale(sz, c=0) (X,Y,Z) = (x,y,c+sz(z-c))

.move(a,b,c) (X,Y,Z) = (x+a,y+b,z+c)

.psym(a,b,c,d) plane symmetry ax+by+cz=d (cf. ax+by+c=0 in 2D).scale (sx,sy,sz) @(xo,yo,zo) (X,Y,Z) = (xo+sx(x-xo),yo+sy(y-yo),zo+sz(z-

zo)).xrot (t ) @(xo,yo,zo) rotation around x-axis passing (xo,yo,zo).yrot (t ) @(xo,yo,zo) rotation around y-axis passing (xo,yo,zo).lrot (t, a,b,c) @(xo,yo,zo) rotation about line direction (a,b,c).cosrot( a,b,c) @(xo,yo,zo) rotation from (0,0,1) to (a,b,c)

Whether a certain Spoke is applied to 2D or 3D geometries can be determined by counting the number of arguments. For example, ".move(a,b)" is for 2D, while ".move(a,b,c)" is for 3D.

22

Page 23: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

Multiple 3D curves can be plotted by using ‘plot+’. Figure 19 shows a curve where Spoke ‘yrot’ (rotation around the y-axis) is applied

#> plot .@t[501](0,5) ( exp(0.6*t), 30*t, 10*t ) .cyl.move(0,30,0) .yrot(pi/6); #> plot+ .@t[501](0,5) ( exp(0.6*t), 30*t, 10*t ) .cyl.yrot(-pi/6); // (r,t,z)

Figure 19 3D curve

The axis plane is always shown by default. The axis plane in the screen can be hidden by placing the mouse on the screen and typing ‘a’ in the keyboard. Subsequently, typing ‘b’ in the keyboard helps to change the color of background and typing ‘x’ in the keyboard helps to change the color of the axis planes. Zooming in and out can be also handled by the mouse wheel located in the center of the mouse. A view angle can be also modified by placing the mouse in the plot window and moving the mouse properly.

In Figure 20, several degrees of Chebyshev polynomials T n(x) are drawn. The syntax for Chebyshev polynomial shall be discussed later.

#> plot .@t[2] (-1,1) ( t, 0, .T_0 (t) ); #> plot+.@t[51] (-1,1) ( t, 2, .T_2 (t) ); #> plot+.@t[51] (-1,1) ( t, 4, .T_4 (t) ); #> plot+.@t[101] (-1,1) ( t, 6, .T_10(t) ); #> plot+.@t[201] (-1,1) ( t, 8, .T_20(t) ); #> plot+.@t[501] (-1,1) ( t, 10, .T_40(t) ); #> plot+.@t[1001](-1,1) ( t, 12, .T_60(t) );

23

Page 24: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

Figure 20 3D curves for Chebyshev polynomial T n(x)

Figure 21 presents a bulb-like geometry generated by 3D curves by

#> plot .@t[1001](0,30*pi) ( 1, t/30, t ) .sph; // (R,P,T) #> plot+.@t[1001](0,30*pi) ( 0.2, t, t/60 ) .cyl.move(0,0,1); // (r,t,z)

Figure 21 A bulb-like geometry drawn by 3D curves

And Figure 22 is a 3D revision of Butterfly and Rose discussed earlier.

#> (a,b) = (53,7); #> plot .@t[501](0,2*pi*a) ( 5*sin(b*t), t, 0 ).cyl; #> plot+.@t[501](0,10*pi) ( exp(cos(t))-2*cos(4*t)+(sin(t/12))^5, t, 3 ).cyl;

24

Page 25: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

As for the curves for butterfly and rose, refer the literature cited in Figure 10.

Figure 22 3D plot of butterfly and rose

Section 2-7 Surfaces in 3D

■ Built-In Geometries. Commonly encountered in 3D are the sphere, ellipsoid, torus, disk and plane, and all of these geometries are installed in Cemmath as built-in geometries with the following syntax

.sphere [np=31,nt=31, gp=1,gt=1] (R )

.ellipsoid [np=31,nt=31, gp=1,gt=1] (a,b,c )

.torus [np=31,nt=31, gp=1,gt=1] (a,b )

.disk [nr= 2,nt=31, gr=1,gt=1] (R )

.plane [nx= 2,ny= 2, gx=1,gy=1] (a,b,c, side=1)

.vector [scale=1, headscale=1,headangle=30](a,b,c) .frustum [nr=3,nt=21,nz=4, gr=1,gt=1,gz=1] (a,b,h ) .toroid(size) .trefoil(size) .mobius(size) .klein (size)

Since the grid span denoted by ‘[ ]’ has all default values, it can be omitted unless one wants to change the grid property. To draw a sphere of radius 1 at origin with 21 ×21 uniform mesh, one just needs to input

#> plot.sphere[21,21](1) ; // 21 x 21 uniform mesh

25

Page 26: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

Then, the result can be seen in the left side of Figure 23. A 21 ×21 mesh net of a sphere can be seen in the right side of Figure 23 (typing ‘w’ in the keyboard transforms surface to mesh net).

Figure 23 A sphere of radius 1 at the origin.

By utilizing ‘.hold’, we can draw a series of spheres located around a circle. The following commands

#> n = 21;; r = 1;; #> .hold;

for.i(0,9) plot .sphere[n,n](r) .move(4*cos(i*2*pi/10),4*sin(i*2*pi/10),0) ;

#> plot;

result in Figure 24.

Figure 24 Spheres of radius 1

Figure 25 shows three torus as well as an ellipsoid rotated around the z-axis created by

26

Page 27: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

#> n = 21;; (a,b) = (4,1);; #> .hold; plot .torus[n,n](a,b) ; plot .torus[n,n](a,b).cyclic.move(0, 5,0); plot .torus[n,n](a,b).cyclic.move(0,-5,0);#> plot;

#> (a,b,c) = (8,3,2);; #> plot .ellipsoid(a,b,c).zrot(pi/6); // plot.sphere(1).scale(8,3,2).zrot(pi/6)

Figure 25 Three torus and an ellipsoid

The built-in geometry ‘disk’ is generated in the xy–plane, as shown in Figure 26a; see the following command

#> plot .disk(1).xscale(2);

Also, a plane with a side-length 1 and a normal direction (1,1,1) can be generated by

#> plot .plane(0,0,1).cosrot(1,1,1).togo(P); P; // same as plot.plane(1,1,1);

where the result is shown in Figure 26b. Examining the vertex data in the variable ‘P’

P = [ -0.28868 -0.28868 0.57735 ] [ -0.5 0.5 0 ] [ 0.5 -0.5 0 ] [ 0.28868 0.28868 -0.57735 ]

27

Page 28: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

clearly reveals that all the points are indeed perpendicular to (1,1,1).

Figure 26 An enlarged disk and a plane

In addition, Figure 27 shows a pyramid and a conical frustum (cones with top cut off) generated by the built-in geometry ‘frustum’

#> plot .frustum[5,26,9] ( 2,1,3 );//frustum[nr=3,nt=21,nz=4, gr=1,gt=1,gz=1](a,b,h);#> plot+.frustum[2, 5,2] ( 2,0,3 ).xmove(5);

Figure 27 Frustums

■ Parameterized Surfaces. In the three-dimensional space, a surface can be parameterized with the aid of two parameters u , v for which a ≤ u ≤b and

c (u ) ≤ v≤ d (u) may be specified. The standard form of the parameterized

28

Page 29: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

surface reads

x=x (u , v ) , y= y (u , v ) , z=z (u , v )

Then, the parameterized surface can be plotted by the following Cemmath command

plot .u[nu=31,gu=1](a,b) .v[nv=31,gv=1](c(u),d(u)) (<<opt>>,x(u,v),y(u,v),z(u,v))

Unlike the parameterized curves utilizing the character ‘@’, the parameterized surfaces do not adopt ‘@’ to represent parameterization. This is because three expressions are always included inside the Stem. The Cemmath is wise enough to distinguish whether a parameterized surface is described or not by counting the number of Hub variables as well as the number of expressions inside the Stem.

On the contrary to the case of 2D, it is crucial to remember that the Umbrella ‘plot’ can draw only 1 surface at a time. Whenever multiple surfaces are desired in one layout, ‘plot+’ must be used for each surface.

One of the striking features of Hub is that it can handle multi-dimensionality with ease. In the above, the Hub is composed of two grid spans in both u and v directions. Since the grid span in each spatial coordinate is

separated by dot, it is extremely easy to grasp the range of grid span in each direction. Furthermore, the second grid span can have functions in terms of the variable defined in the first grid span.

■ Surfaces z=z (x , y) For example, a surface given by the following

−3 ≤ x ≤ 3 ,−√10−x2≤ y ≤3+ xz=( x2+ y2 ) exp(1− x2− y2)

can be easily generated by the input

#> plot .x[21](-3,3) .y[21](-sqrt(10-x*x), 3+x) ( (x*x+y*y)*exp(1-x*x-y*y) );

29

Page 30: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

and the result with 21 ×21 mesh grid is shown in Figure 28. Remember that the grid mesh is 51 ×51 by default.

Figure 28 3D surface

■ Surfaces z=z (r , θ) in the polar coordinate. When the xy-plane is expressed in terms of the polar coordinate (r , θ), implementing this case just requires a use of the Spoke ‘cyl’.

plot .u[nu=31,gu=1](a,b) .v[nv=31,gv=1](c(u),d(u)) (<<opt>>,r,t,z).cyl

where r(u,v),t(u,v),z(u,v) are functions of u and v.

For example,

#> plot.r[41](0,5) .t[21](0,3*pi/2) ( r,t,sin(r*r) ) .cyl; #> plot.t[21](0,3*pi/2) .r[41](0,5) ( r,t,sin(r*r) ) .cyl;

corresponds to the result shown in Figure 29.

30

( , )z z x y

Page 31: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

Figure 29 A surface in the polar coordinate

■ Surfaces in the spherical coordinate. When the azimuthal φ and cone θ angles are used to define a surface r=r (φ , θ), the corresponding syntax becomes

plot .u[nu=31,gu=1](a,b) .v[nv=31,gv=1](c(u),d(u)) (<<opt>>,r,p,t).sph

where r(u,v),p(u,v),t(u,v) are functions of u and v.

The coordinate transformations x=r sin φ cosθ , y=r sin φ sinθ , z=r cos φ are handled internally. It should be noted that the cone angle must appear first to keep the right-hand rule. Figure 30 illustrates two interesting geometries, a wrinkled sphere and a bumpy sphere (see ref [3]). The mathematical expressions for r=r (φ , θ) are already included in the figure, and thus are not repeated.

#> plot.p[21](0,pi).t[51](0,2*pi) ( 1+0.2*sin(8*t)*sin(p) ,p,t ).sph; #> plot.p[41](0,pi).t[51](0,2*pi) ( 1+0.2*sin(8*t)*sin(4*p),p,t ).sph;

31

Page 32: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

Figure 30 Surfaces in the spherical coordinates

■ General Parameterized Surfaces. In Figures 31-36, several interesting parameterized surfaces are plotted. Since the mathematical expressions are all together specified in the corresponding figure, they are not repeated here.

#> (a,b) = (4,2); #> plot.u(0,pi).v(-1,1) ( #> plot.u(-pi,pi).v(-pi,pi) (

(a-v*sin(u))*cos(b*u), sin(u)*(7+cos(u/3-2*v)+2*cos(u/3+v)),(a-v*sin(u))*sin(b*u), cos(u)*(7+cos(u/3-2*v)+2*cos(u/3+v)),v*cos(u) ); sin(u/3-2*v)+2*sin(u/3+v) );

Figure 31 Mobius strip [3] Figure 32 Umbilic torus [3]

#> plot.u(-pi,pi).v(-pi,pi) ( 3+sin(u)*(7-cos(3*u-2*v)-2*cos(3*u+v)), 3+cos(u)*(7-cos(3*u-2*v)-2*cos(3*u+v)), sin(3*u-2*v)+2*cos(3*u+v) );

Figure 33 Strip with multiple twists [3]

#> plot.u(-pi,pi).v(-pi,pi) (

32

Page 33: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

3+sin(u)*(7-cos(3*u-2*v)-2*cos(3*u+v)), 3+cos(u)*(7-cos(3*u-2*v)-2*cos(3*u+v)) , sin(3*u-2*v)+2*sin(3*u+v) );

Figure 34 Double strips [3]

#> plot .u(0,2*pi).v(0,2*pi) ( << a = 2-cos(u), b = a*cos(v), xu = 3*cos(u)*(1+sin(u)), yu = -8*sin(u) >>, u < pi ? xu + b*cos(u) : xu-b, u < pi ? yu - b*sin(u) : yu, -a*sin(v) );

Figure 35 Klein bottle

(a,b,c,d) = (0.5, 0.3, 0.5, 0.1);; plot .u[51](0,2*pi).v[7](0,2*pi) (

33

Page 34: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

<< r = a + b*cos(3*u), vp = < r*cos(2*u), r*sin(2*u), c*sin(3*u) >, vq = < -1.5*b*sin(3*u)*cos(2*u) - vp.y, -1.5*b*sin(3*u)*sin(2*u) + vp.x, 1.5*c*cos(3*u) > .unit, vn = < vq.y, -vq.x, 0 > .unit, vq ^= vn >>, vp + d*( vn*cos(v) + vq*sin(v) ) // vertex );

Figure 36 Trefoil knot

Section 2-8 Revolution in 3D

■ Revolution around a line. A large amount of mathematically important surfaces can be generated by revolution around a certain line, for example the x-axis. Cemmath provides such geometries by means of Spokes summarized below.

.xrev [nt=21,gt=1](t1=0,t2=2*pi)

.yrev [nt=21,gt=1](t1=0,t2=2*pi)

.zrev [nt=21,gt=1](t1=0,t2=2*pi)

.lrev [nt=21,gt=1](t1,t2 a,b,c) line ax+by+c=0

Much like the grid spacing treated so far, the spanning properties n , g are placed within ‘[ ]’. In generating a revolution surface, only a single connected curve in the xy-plane can be used as a generating curve, and only one revolution surface is obtained thereby. Note especially that the rotation around the z-axis always creates a flat surface. The range of rotation angle can be selected at users’ choice between 0 and 2 π . A few examples are listed below.

#> plot.star(1).move(0,2) .xrev(0,pi); // xrev[21,1](0,2*pi)#> plot.x[11](-1,1) ( x^3 ) .yrev. cyclic; #> plot.x[10](pi,2*pi) ( sin(x) ) .zrev[11](0,pi) ; #> plot.t[21](0,2*pi) (1).cyl.move(2,1).lrev(0,2*pi, 1,1,0); // line x+y = 0

and the results are displayed in Figures 37-40.

34

Page 35: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

#> plot.star(1).move(0,2) .xrev(0,pi); // xrev[21,1](0,2*pi,0)#> plot.x[11](-1,1) ( x^3 ) .yrev. cyclic;

Figure 37 Revolution around x-axis Figure 38 Revolution around y-axis

#> plot.x[10](pi,2*pi) (sin(x)).zrev[11](0,pi); #> plot.t[21](0,2*pi) (1).cyl.move(2,1).lrev(0,2*pi, 1,1,0);

Figure 39 Revolution around z-axis Figure 40 Revolution around a line

When multiple surfaces intersect one another, hidden surfaces cannot be shown. This can be seen by the following commands

#> plot .x[2](-2,2)(1).xrev; plot+.x[2](-2,2)(1).xrev .zrot(pi/2); plot+.x[2](-2,2)(1).xrev .yrot(pi/2);

and the results are shown in Figure 41.

35

Page 36: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

Figure 41 Intersecting surfaces

■ Revolution with Closed Ends. When a single connected curve is revolved around a given line, the surface may be open at both ends. To cover open ends, we use two Spokes discussed above

.side1[n=3,g=1] // starting-side closing

.side2[n=3,g=1] // ending-side closing

An example of revolution surface with closed ends is

#> plot .x[21](0,2) ( exp(-0.5*x) ) .xrev .side2; #> plot .x[3]( 1, 2)( x) .xrev.side1.side2;#> plot+.x[3]( 1, 2)( x) .yrev.side1;#> plot+.x[3](-2,-1)(-x) .xrev.side2;#> plot+.x[3](-2,-1)( x) .yrev.side2;

and the result is in Figure 42. Remember that ‘xrev[21,1](0,2*pi)’ is the same as ‘xrev’ from default options.

Figure 42 Revolution with one closed end

36

Page 37: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

One interesting feature of revolution with sides is that a pyramid can be also drawn. When the grid size of rotation is 5, angle spacing becomes 360/(5-1)=90, and one side of rotation looks like a square. Therefore, the following command

#> plot.x[6](0,1) ( 1-x ) .xrev[5] .side1;

creates a pyramid shown in Figure 43.

Figure 43 A pyramid (top and bottom view)

Figure 44 illustrates the case of using the upper-step or lower-step function, given by

#> plot.x[13](-pi,2*pi) ( 3+cos(x) ) .ustep .xrev .side1 .side2;

Figure 44 Revolution of a step-function

37

Page 38: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

Section 2-9 Popped and Filled Surfaces in 3D

■ Popped Surface. A popped surface is defined here to be a surface obtained by popping the curve in the xy–plane into the z-axis. It should be noted that only one curve can be popped by Spoke ‘zpop’ the syntax of which is

.zpop[nz=3,gz=1] (height,ratio=1)

An example of popped surfaces are obtained by

#> plot .x[21](0,2*pi) (sin(x)) .zpop[5](2); #> plot+ .star(1) .move(0.5*pi,0) .zpop(2); #> plot+ .star(1) .zpop(2,0.5).move(1.5*pi,0,0);

and is displayed in Figure 45.

Figure 45 Popped surfaces from 2D curve

■ Popped Surfaces with Sides. Any single curve in the xy-plane can also be popped along the z-direction with sides at bottom, top and inside. The syntax for Spoke ‘zpop’ is extended

.zpop[nz=3,gz=1] (height,ratio=1) &&[nr=3,gr=1](Rb=0,Rt=0){bot=1,top=1,inside=0}

38

Page 39: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

The grid in the side direction is added together with

(Rb=0,Rt=0)

where Rb the relative magnitude of the bottom hole, and Rt that of the top hole. In addition

{ bottom=1,top=1,inside=0}

determines whether each end is closed or not.

The simplest case of ‘zpop’ would be ‘frustum’ discussed earlier, since

.frustum[nr,nt,nz](a,b,h) is the same as .circle[nt](a).zpop[nz](h,b/a) &&[nr]

This can be confirmed by taking out the final data points, for example

#> plot .frustum[4,5,3](2,1,3) .togo(A);; #> plot+ .circle[5](2).zpop[3](3,1/2) &&[4].togo(B);; #> A-B;

The result

A-B= [ 0 0 0 ] [ 0 0 0 ] [ 0 0 0 ] [ 0 0 0 ] [ 0 -0 0 ] [ 0 0 0 ] [ 2.9141e-008 0 0 ] [ 0 1.0066e-007 0 ] …

[ 0 0 0 ] [ 0 -0 0 ]

shows no difference between the final data points A and B.

Figure 46 displays the role of surface options and the effect of varying arguments very clearly.

39

Page 40: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

#> T = (0,1.5*pi).span(31);;#> .hold; plot[@T]( 3*cos(T),2*sin(T) ).zpop[6](3,0.5) &&{1,1,0}.move(0,0,10); plot[@T]( 3*cos(T),2*sin(T) ).zpop[6](3,0.5) &&{0,1,0}.move(8,0,10); plot[@T]( 3*cos(T),2*sin(T) ).zpop[6](3,0.5) &&{1,0,0}.move(16,0,10); plot[@T]( 3*cos(T),2*sin(T) ).zpop[6](3,0.5) &&{0,0,1}.move(0,0,5); plot[@T]( 3*cos(T),2*sin(T) ).zpop[6](3,0.5) &&{1,0,1}.move(8,0,5); plot[@T]( 3*cos(T),2*sin(T) ).zpop[6](3,0.5) &&{0,0,0}.move(16,0,5); plot[@T]( 3*cos(T),2*sin(T) ).zpop[6](3,0.5) &&(0.2,0.2){1,1,1}; plot[@T]( 3*cos(T),2*sin(T) ).zpop[6](3,0.5) &&(0.2,0.2){0,1,1}.move(8,0,0); plot[@T]( 3*cos(T),2*sin(T) ).zpop[6](3,0.5) &&(0.2,.2){1,1,0}.move(16,0,0);#> plot;

Figure 46 Variation of surface options {bottom,top,inside} in Spoke ‘zpop’

Figure 47 displays interesting construction of 3D shapes from the well-known cardioid by

#> plot .t[31](0,2*pi) ( 1+cos(t) ) .cyl .zpop[6](0.5)&&[21](0.5,0.5){1,1,1}; #> plot+ .t[31](0,2*pi) ( 1+cos(t) ) .cyl .zpop(0.5)&&[21] .ymove(3);

40

Page 41: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

Figure 47 3D Variation of cardioids in 3D

■ Filled Surface. A filled surface is defined here to be a surface obtained by filling two curves. It should be noted that only one filled surface can be generated by Spoke ‘fill’ the syntax of which is

.fill[n=21,g=1]

Of course, a filled surface is always flat and lies in the xy-plane. It is possible to move or rotate a filled surface by applying appropriate Spokes. An example of a filled surface is obtained by

#> plot.x[11](-2,2) ( x*x-4, 1+cos(x) ) .fill[11];

and is displayed in Figure 48.

41

Page 42: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

plot.x[11](-2,2) ( x*x-4, 1+cos(x) ) .fill[11];

Figure 48 Filled surface between two curves

Section 2-10 Summary of Syntax

In the following, the default values of ‘@(xo,yo)’ or ‘@(xo,yo,zo)’ are always xo=0, yo=0, zo=0. The Spoke ‘polar’ can be alternatively used as ‘cyl’ (an abbreviation of cylindrical). A special character ‘@’ is only used to denote parameters for 2D and 3D curves.

■ Syntax for 2D curve(s)

plot .x[n=51,g=1](xa,xb) ( <<opt>>,f(x), … ) 2D curve(s) plot .t[n=51,g=1](ta,tb) ( <<opt>>,r(t), … ) .cyl 2D curve(s)

plot .@u[n=51,g=1](ua,ub) ( <<opt>>,x(u),y(u) ) 2D curve (single)plot .@u[n=51,g=1](ua,ub) ( <<opt>>,r(u),t(u) ) .cyl 2D curve (single)

■ Syntax for 2D Phase Diagram

plot .u[n=21,g=1](a,b) .v[n=21,g=1](c(u),d(u)) ( u', v' ) .phase[scale=1,headscale=1,headangle=30]

■ Syntax for 3D curve (only a single curve)

plot .@u[n=51,g=1](a,b) ( <<opt>>,x(u),y(u),z(u) ) // 3 functions plot .@u[n=51,g=1](a,b) ( <<opt>>,r(u),t(u),z(u) ) .cyl plot .@u[n=51,g=1](a,b) ( <<opt>>,r(u),p(u),t(u) ) .sph

■ Syntax for 3D surface (only a sinlge surface)

plot .u[n=31,g=1](a,b) .v[n=31,g=1](c(u),d(u)) (<<opt>>,x,y,z) plot .u[n=31,g=1](a,b) .v[n=31,g=1](c(u),d(u)) (<<opt>>,r,t,z) .cylplot .u[n=31,g=1](a,b) .v[n=31,g=1](c(u),d(u)) (<<opt>>,r,p,t) .sph

where

x=x(u,v), y=y(u,v), z=z(u,v) r=r(u,v), t=t(u,v), z=z(u,v)

42

Page 43: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

r=r(u,v), p=p(u,v), t=t(u,v)

■ Built-in geometries in 2D

.circle [nt=51,gt=1] (radius)

.ellipse [nt=51,gt=1] (a,b )

.polygon [nvert,gt=1] (radius) // nvert >= 3

.triangle (a,b,c )

.square (a )

.rectangle (a,b )

.parallel (a,b, theta )

.trapezoid (a,b, height)

.star (radius ) .point (a,b).line (x1,y1, x2,y2)

.vector [scale=1,headscale=1,headangle=30] (a,b)

■ Built-in geometries in 3D

.sphere [np=31,nt=31, gp=1,gt=1] (R )

.ellipsoid [np=31,nt=31, gp=1,gt=1] (a,b,c )

.torus [np=31,nt=31, gp=1,gt=1] (a,b )

.disk [nr= 2,nt=31, gr=1,gt=1] (R )

.plane [nx= 2,ny= 2, gx=1,gy=1] (a,b,c, side=1)

.frustum [nr=3,nt=21,nz=4, gr=1,gt=1,gz=1] (a,b,h)

.vector [scale=1,headscale=1,headangle=30] (a,b,c)

.line (x1,y1,z1, x2,y2,z2)

.toroid(size)

.mobius(size)

.klein(size)

.trefoil(size)

■ Spokes common

.xlog X = log10(x) in plot (no change in data) .ylog Y = log10(y) in plot (no change in data).xsym(a=0) X=2*a-x symmetry about line x=a

.ysym(b=0) Y=2*b-y symmetry about line y=b.xmove(a) X=x+a translate in x-direction by a

.ymove(b) Y=y+b translate in y-direction by b.xscale(sx,a=0) X=a+sx*(x-a) elongate in x-dir about line x=a

.yscale(sy,b=0) Y=b+sy*(y-b) elongate in y-dir about line y=b.xmean(xm) extracts a mean value of x.ymean(ym) extracts a mean value of y

43

Page 44: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

.togo(A) extracts matrix A for data points

plot; draw a plot immediatelyplot+.hold; hold+; hold the current plot for overwriting.hold; new and hold

■ Spokes for 2D curves

.cyl must be the first Spoke

.flip (X,Y)=(y,x) symmetry about line y = x .loglog (X,Y)=(log10(x), log10(y)).move(a,b) (X,Y)=(x+a,y+b) translate by a vector (a,b).osym @(xo,yo) (X,Y)=(2*xo-x,2*yo-y) symmetry about point (xo,yo).scale(sx,sy)@(xo,yo) (X,Y)=(xo+sx*(x-xo),yo+sy*(y-yo)) .zrot(t) @(xo,yo) rotate counterclockwise about (xo,yo).lsym(a,b,c) symmetry with respect to line ax+by+c = 0 .lstep lower-step function .ustep upper-step function .xstem stem with respect to the x-coordinate.ystem stem with respect to the y-coordinate.xystem stem with respect to the x- and y-coordinates.stem stem with circle.merge make all curves to be a single curve.link connect piecewise curves.movelink connect piecewise curves to the last ending point

.copy[n] (dx,dy) duplicate n curves and move by (dx,dy) .copylink[n] (dx,dy) copy[n](dx,dy) and make all curves to be a single curve.allout(A) extracts matrix A for all the vertex data.info print out information on curves and vertex

.xrev [nt=21,gt=1](t1=0,t2=2*pi, a=0)

.yrev [nt=21,gt=1](t1=0,t2=2*pi, b=0)

.zrev [nt=21,gt=1](t1=0,t2=2*pi, c=0)

.lrev [nt=21,gt=1](t1,t2 a,b,c) line ax+by+c=0

.zpop [nz= 3,gz=1](h,ratio=1) &&[nr=3,gr=1] (Rb=0,Rt=0){bottom=1,top=1,inside=0}.fill [nf=21,gf=1]

■ Spokes for 3D curves and surfaces

.cyl must be the first Spoke

.sph must be the first Spoke

44

Page 45: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

.zlog Z=log10(z)

.zmove(c) Z=z+c

.zscale(sz, c=0) Z=c+sz*(z-c)

.zsym (c=0) Z=2*c-z symmetry about plane z=c

.psym(a,b,c,d) plane symmetry ax+by+cz=d

.zmean(zm) extracts a mean value of z

.cyclic (X,Y,Z)=(z,x,y)

.move(a,b,c) (X,Y,Z)=(x+a,y+b,z+c)

.osym @(xo,yo,zo) (X,Y,Z)=(2*xo-x,2*yo-y,2*zo-z) point symmetry

.scale(sx,sy,sz) @(xo,yo,zo) (X,Y,Z)=(xo+sx(x-xo),yo+sy(y-yo),zo+sz(z-zo))

.xrot (t ) @(xo,yo,zo) rotation around x-axis passing (xo,yo,zo)

.yrot (t ) @(xo,yo,zo)

.zrot (t ) @(xo,yo,zo)

.lrot (t, a,b,c) @(xo,yo,zo) rotation about line direction (xo,yo,zo)

.cosrot( a,b,c) @(xo,yo,zo) rotation from (0,0,1) to (xo,yo,zo)

■ More Spokes Discussed in Chapter 3

.int1da (f(x,y)) (fscalar) .intxxda(f(x,y)) (fscalar)

.intxda (f(x,y)) (fscalar) .intxyda(f(x,y)) (fscalar)

.intyda (f(x,y)) (fscalar) .intyyda(f(x,y)) (fscalar)

.intdl (f(x,y,z), … ) (fscalar, …)

.intda (f(x,y,z), … ) (fscalar, …)

.intdL * (Fx(x,y,z),Fy(x,y,z),Fz(x,y,z)) (fscalar)

.intdL ^ (Fx(x,y,z),Fy(x,y,z),Fz(x,y,z)) (Fmatrix)

.intdL (f(x,y,z)) (Fmatrix)

.intdA * (Fx(x,y,z),Fy(x,y,z),Fz(x,y,z)) (fscalar)

.intdA ^ (Fx(x,y,z),Fy(x,y,z),Fz(x,y,z)) (Fmatrix)

.intdA (f(x,y,z)) (Fmatrix)

.area(area)

.volume(vol)

Section 2-11 References

[1] P.M. Maurer, A rose is a rose ..., Math. Monthly, 94 (1987), pp. 631-645.

[2] T.H. Fay, A study in step size, April issue, Mathematics Magazine (1997).

[3] R.E. Larson, R.P. Hostetler, B.H. Edwards, Calculus with Analytic Geometry, 6ed.,Houghton Mifflin Co., (1998)

45

Page 46: Web view[100] 002 revised on 2012.12.03. cemmath. The Simple is the Best. Chapter 2 Plot. 2-1 What is the Concept of Umbrella. ... symmetry with respect to line ax+by+c = 0

[100] 002 Chapter 2 Plot, Tutorial by www.msharpmath.com

[4] MATLABⓇ 7, Mathematics, The MathWorks Inc. (2009).

[5] D.J. Higham and N.J. Higham, MATLAB(R) Program GuideBook, 2ed., SIAM (2005).

//----------------------------------------------------------------------------// end of file//----------------------------------------------------------------------------

46