**
**

{version = 1.43; (* of cisq.p 1989 December 19} (* begin module describe.cisq *) (* name cisq: circle to square synopsis cisq(cisqp: in, xyin: out, output: out) files cisqp: parameters to control the program First line: lowest value of m, mlo. Second line: highest value of m, mhi. Third line: increment in the value of m, mstep. Fourth line: desired radius of a circle if m = 2, reffective. Fifth line: number of steps to take to move around 360 degrees. Sixth line: A factor by which to increase the value of theta, spinfactor. 1 gives a square, 1.5 gives a hexagon. xyin: input to the xyplo program. Curves that are close to integer values of n have the symbol m, others have the symbol r. This allow them to be distinguished by the graphics routines. output: messages to the user description Plot the equation |x|^m + |y|^m = |reffective|^m where reffective is the "effective" radius of the curve, |x| is the absolute value of x, and ^ means to raise to the mth power. This gives a line if m = 1, a circle if m = 2 and approaches a square as m -> infinity! The method for producing the curves is to re-express the equation in polar coordinates. One must be a bit careful to distinguish between the effective radius (reffective) and the current polar coordinate (r). After making this distinction we can write: x = r cos theta y = r sin theta and rearrange to solve for r, while keeping reffective fixed as it should be. Dividing the basic formula by r (>0) and converting to polar coordinates gives: (reffective/r)^m := / ((|cos(theta)|)^m + (|sin(theta)|)^m); To do this in Pascal, we have to use the form, a^m = exp(m*ln(a)). This gives: exp(m * ln(r/reffective)) := 1 / ( exp(m * ln(abs(cos(theta)))) + exp(m * ln(abs(sin(theta)))) ) where we have also introduced the absolute function on the sine and cosine. One more rearrangement gives r := reffective * exp( ln( 1 / ( exp(m * ln(abscostheta)) + exp(m * ln(abssintheta)) ) ) / m); which is the form used in the code. In the cases where the sine or cosine are zero (ie on the axes), we must not calculate at all, to avoid log of zero. We simply set r = reffective in those cases. The program has a special feature to speed up the angle of the calculation (theta) so that it moves faster than the angle at which the graph is plotted. With a factor of 3/2, the four corners become 3/2 * 4 = 6 corners, and we obtain a hexagon. examples To produce a nice square, use the parameters: 0.5 First line: lowest value of m. 5.0 Second line: highest value of m. 0.1 Third line: increment in the value of m 1 Fourth line: desired radius of a circle if m = 2. 100 Fifth line: number of steps to take to move around 360 degrees. 1 Sixth line: A factor by which to increase the value of theta. 1 gives a square, 1.5 gives a hexagon. To produce a hexagon transformed into a circle, use the parameters: 1.5 First line: lowest value of m, mlo. 2.0 Second line: highest value of m, mhi. 0.1 Third line: increment in the value of m, mstep. 1.0 Fourth line: desired radius of a circle if m = 2, reffective. 100 Fifth line: number of steps to take to move around 360 degrees. 1.5 Sixth line: A factor by which to increase the value of theta, spinfactor. 1 gives a square, 1.5 gives a hexagon. It is not clear why one has to use the lowest value of n as the same as the theta factor (6th parameter), but it works! (One would have to prove that with these parameters one gets an exact straight hexagon edge.) documentation Inspired by: > Article 7568 in sci.math: > From: pvmg0487@uxa.cso.uiuc.edu > Subject: hexagonal cone function sought > Message-ID: <107700002@uxa.cso.uiuc.edu> > Date: 22 Nov 89 22:25:00 GMT > > I would like to generate a 3-D cone like object, but with a hexagonal > base. Any suggestions as to an appropriate equation? > > Thanks -- Vernon > Article 7578 in sci.math: > From: toms@ncifcrf.gov (Tom Schneider) > Subject: Re: hexagonal cone function sought > Message-ID: <1405@fcs280s.ncifcrf.gov> > Date: 25 Nov 89 01:18:14 GMT > References: <107700002@uxa.cso.uiuc.edu> > Reply-To: toms@fcs260c2.UUCP (Tom Schneider) > Organization: National Cancer Institute, Frederick > Lines: 30 > > In article <107700002@uxa.cso.uiuc.edu> pvmg0487@uxa.cso.uiuc.edu writes: > > > >I would like to generate a 3-D cone like object, but with a hexagonal > >base. Any suggestions as to an appropriate equation? > > > >Thanks -- Vernon > > Well, that's pretty surprising, since just today I was thinking about a > function that does almost exactly what you want! It turns out that the > equation x^n + y^n = r^n is a line (diamond) if n = 1, a circle if n = 2 and > approaches a square as n -> infinity! So all one needs to do is express this > in polar notation, and then scrunch an extra two corners in to get what you > want! > > First, use the form x^n + y^n = rmax^n (to avoid confusion!) and substitute x > = r cos(theta), y = r sin(theta). Divide both sides by r^n, and rearrange to > get r expressed as a function of theta. To get the powers, I had to use a^b > = exp(b*ln(a)). The thing is symmetrical around the 4 quadrants, so I > avoided logs of negative numbers by taking the absolute values of the sine > and cosine functions. Also, at angles of n*pi/2, one gets division by zero, > so just substitute the desired radius. > > I have done this by writing a Pascal program that will do the job. Pretty! > It turns out that to get a hexagon, you have to plot between n=1.5 and n=2 > because of the scrunching. Email me if you want a copy of the program. > > Tom Schneider > National Cancer Institute > Laboratory of Mathematical Biology > Frederick, Maryland 21701-1013 > toms@ncifcrf.gov > From daemon Tue Nov 28 09:34:41 1989 > Return-Path: <daemon> > Date: Tue, 28 Nov 89 08:35:52 -0600 > From: Paul Vernon McDonald <pvmg0487@uxa.cso.uiuc.edu> > Message-Id: <8911281435.AA01048@uxa.cso.uiuc.edu> > To: toms@ncifcrf.gov > Subject: Pascal code for hexagon > > Tom, > I'd be most grateful to receive your code, if you are willing to share it. > I curently have a working version of the hexagon, done in piecewise > fashion, but I'd be interested in a generic solution. In fact I plan > to use other shapes in the future, so your code may be of great help. > > Thanks, > > Vernon McDonald > University of Illinois > Department of Kinesiology > Urbana, IL, 61801 > vmcdonald@uiuc.edu > > From toms Tue Nov 28 13:17:17 1989 > To: pvmg0487@uxa.cso.uiuc.edu > Subject: Cisq > > Vernon: > Sure, I wrote the code mostly because of your posting. But actually it > has suddenly become very important to my work (it's a long story...) and so > it is useful to me to have it. I have to brush it up a bit and I will > send it to you. If you have a PostScript printer, then you may also > want the xyplo program, which produces PostScript x-y plotting of data. > This made writing cisq (circle square) easier because I only needed to > create the right numbers and xyplo did the graphics for me. > Tom see also xyplo.p, the Pascal program that produces PostScript x-y plotting graphics. author Thomas Dana Schneider bugs One might also want to produce the hexagon for INCREASING values of n, rather than being confined into the region n=1.5 to 2. It seems that to do this requires that one do a fancy job of warping the square region into the appropriate triangular region. This should be pretty easy with the right afine transformation, but the program doesn't have that feature in it. Fortunately, it is not necessary. technical notes *) (* end module describe.cisq *) {This manual page was created by makman 1.44}

Viewing Files Accessibility