An entire real range plotting algorithm via computer graphics

An entire real range plotting algorithm via computer graphics

Comput. & Graphics Vol. 1I, No. 3, pp. 305-308, 1987 0097-8493/87 $3.00 + .00 © 1987 Pergamon Journals Ltd. Printed in Great Britain. Short Technic...

205KB Sizes 1 Downloads 52 Views

Comput. & Graphics Vol. 1I, No. 3, pp. 305-308, 1987

0097-8493/87 $3.00 + .00 © 1987 Pergamon Journals Ltd.

Printed in Great Britain.

Short Technical Notes/Technical Forum/Systems A N ENTIRE REAL R A N G E P L O T T I N G A L G O R I T H M VIA COMPUTER GRAPHICS KUMAR K. TAMMA,* Department of Mechanical Engineering, University of Minnesota, Minneapolis, MN 55455 and WILLIAM B. SQUIRE1" and BRIAN L. DOWLER:~ Department of Mechanical and Aerospace Engineering, West Virginia University, Morgantown, WV 26506-6101 Abstract--This paper presents a general computer algorithm that has been successfully implemented and uses computer-aided graphics techniques to plot the representative behavior of any arbitrary function over its entire real range, that is, -oo to + oo. Several interesting graphics plots, for both two- and three-dimensional functions are shown as examples. INTRODUCrION In certain engineering applications it is desirable to examine the behavior of a function as it approaches infinity. A computer algorithm has been successfully implemented that uses computer-aided graphics techniques to plot the representative behavior of an arbitrary function over its entire real range, i.e., - o r to +oo. Such representations could be very useful for various response studies. Although it is possible to plot the behavior of a function with a multitude of evenly spaced intervals over a large range, e.g., - 1 0 0 , 0 0 0 to 100,000, for certain types of analysis, this would be very inefficient. This is because such a large range on a regular Cartesian plot would shadow the details of the behavior of the function at critical points, such as - 1 , 0, and 1. A simple method of covering the entire real range consists of an ordinary Cartesian plot [1] of each functionfrom - 1 to 1, with adjoining adjusted plots for those points whose values lie outside this range. The arrangement of the scale equivalent to the representation is shown in Fig. 1. For two-dimensional functions, the Entire Real Range Plotting ALgorithm (ERRPAL) plots the representative function y = f ( x ) for either 0 < x < oo or - oo < x < oo. Several functions can be plotted on the same graph. The values of each point xi less than - 1 are replaced with [ - 2 . 0 - 1.0/xi], and the values of each point x~ greater than + 1 are replaced with [2.0 - 1.0/xi]. The same is also true for each yi value. The resulting values of x and y all lie in the range - 2 . 0 < x, y < 2.0, but are representative of function values ranging from - oo to + oo. Hence, the behavior around the points - 1, 0, and 1 can be closely monitored using this technique.

* Associate Professor, Department of Mechanical Engineering (To receive Correspondence). 1"Professor, Department of Mechanical and Aerospace Engineering. Graduate Research Assistant, Department of Mechanical and Aerospace Engineering.

It has been found that, in general, an input of approximately 80 n o n u n i f o r m incremented steps for various xi values, ranging from - 3 0 0 0 to 3000 for each function, is sufficient for plotting most curves without the use of curve fitting routines. These increments should be spread out for values larger than 5 or 10, and should be clustered very closely around the points - 1 , 0, and 1. The increments may be spaced in such a way as to be equally spaced (in the x direction) after the values are converted to representative numbers by the ERRPAL algorithm. More incremented steps are needed for a smooth representation of functions typical of y = x / l . 0 E + 6. The aforementioned concepts of representing twodimensional functions over their entire real range has been extended into three dimensions as well. An arbitrary function y = f ( x , z) can be computed, and then plotted over its entire real range via three-dimensional computer graphics techniques. In this case, all x, y, and z values lie in the range - 2 . 0 < x, y, z < 2.0, but are representative of the function values from - o o to +oo. The method has been found useful for plotting general polynomials, but care should be taken in plotting transcendental functions since they may not have any meaning and/or be undefined at infinity. A sample flowchart of the two-dimensional E R R P A L algorithm is outlined in Fig. 2. In Figs. 3-5, the computer graphics plots for various two-dimensional functions are shown. The three-dimensional examples are presented in Figs. 6-8. CONCLUSIONS We have presented a simple and effective approach for displaying functions over their entire real range via computer graphics techniques. Such representations could serve very useful to the general community. REFERENCES

1. L. H. Donnell, A chart for plotting relations between variables over their entire real range. Quarterly of Applied Mathematics 2, 276-277 (1944).

306

K.K. TAMMA 2t al. I

I

0

-I

_%

/

i

I

0

I

0

,:x

x

,:xy

x Fig. 1. Typical arrangement of scale for representing functions over their entire real range.

Input Typical

Functions

Identify ~ Choice of Range .~ For Plot .

0

< --

X. l

<

m

-~ < X. < ~ I Appropriate x. values 1 internall~ suoplied

Appropriate x. values i internally SuPPlied

For each Function y = f(x) Compute the Yi value for each x i

Compute Representative Values if x.<-I xA.= -2 - (I/x i) I i if -ll I if yi<-i

xA. = 2-(I/x.) l I xAi= -2-(i/Yi)

if -l
xAi= Yi

if Yi>l

xA.t = 2-(i/yl )

Plot the function

y = f(x)

Fig. 2. Flow chart for graphic representation of functions over their entire real range.

A n entire real range p l o t t i n g a l g o r i t h m

307 infini t ~

5.0 2.0 l.O

io

0°0

-! .0 -2.0 -tnOtnt

ty

Fig. 3. T w o - d i m e n s i o n a l representation o f y = x 2, y = x 6, a n d y = x ~° over the entire real range. _

lr.¢tnl ty t0.0 5.0

2.0

B

iJ

- -

i

1.0

0.o

Fig. 4. T w o - d i m e n s i o n a l representation o f y = x ]/2, y = x ~/4, y = x z/6, a n d y = x '/2° in the positive real range q u a d r a n t .

/'S"-/

infinity

5.0

//,.Z;

2.0

w

1.o

o o

Fig. 5. T w o - d i m e n s i o n a l representation o f y = x 2, y = x 4, y = x ~/2, a n d y = x ~/4 in the positive real range quadrant.

K. K. TAMMA et aL

308

/. ::',~',,:/~,.c :::;--.~-.'. -::~_.--~.

.X',J'"";':/.,.~., ..,~,,.. ~:,;.-'~-~".-f.~.::."-':". -'~ ........ ...... ~,..~.,...;~,.:~ ,,...".::": ' ':2 .':'. .....

.....~ ; ~ , , ~ i ~ ,

/;I,~"I~ I/Zi~ ! l.~i.,it,~ ," ,

,

,,

~

" :

I

Fig. 6. T h r e e - d i m e n s i o n a l representation o f y = X 2 o v e r entire real range.

'-' ,~-~,.

~

,

~'tl .l./.~,,

I

, ,'" ¢

~L4A,x,)0'.7,4Ni/~/~/l~l~¢/f#,/x~ -I

,

,>.. Y Fig. 7. T h r e e - d i m e n s i o n a l representation o f y = x 2 z 2 over entire real range.

Fig. 8. T h r e e - d i m e n s i o n a l representation o f y = x 4 + z 6 over entire real range.