ideal.1 (CWI) 1.2 85/03/03
.nr 99 \n(.s .nr 98 \n(.f .EN
IDEAL 1
NAME
ideal - troff preprocessor for drawing pictures
SYNOPSIS
ideal [ -p [ -v ] [ -4 ] [ -n ] [ files ]
DESCRIPTION
Ideal is yet another troff (1) preprocessor for drawing figures on a typesetter. A line beginning `.IS' marks the start of an ideal program. An ideal program ends with `.IE' or `.IF'; `.IE' leaves you below the bottom of the picture, while `.IF' (flyback) leaves you at the same place you were when you said `.IS'.

When invoked with the -p option, ideal produces plot (1) instructions. The erases come at every `.IS', and they come fast and furious, so you might prefer using the -4 option, which produces instructions for a Tektronix 4014, and waits at each `.IE' for an input character before erasing and starting the next picture. The -n option produces raw ideal output, which passes unharmed through nroff (1). The -v option produces ditroff (1) input meant for the Versatec V-80, of course ditroff should know about the Versatec by using the flag -Tver.

The building block for ideal programs is a ``box''; boxes look like C functions, in that they are named, and delimited by braces. They may include the following kinds of statements, each terminated by a semicolon:

var declares one or more complex variables local to the box. Variable names are made up of letters and digits, and start with a letter; do not use any of the following keywords as variable names: at, bdlist, boundary, box, conn, construct, draw, exterior, interior, left, opaque, put, right, spline, text, to, using, var

equation declares relative positions of significant points of the box

conn asks for a straight-line path through named points

pen asks for a box to be replicated along a line between two points

left left-justifies text with respect to a point

text centers text with respect to a point

right right-justifies text with respect to a point

spline draws a spline guided by the named points

put asks for an instance of a box to be drawn

opaque asks for a box to erase lines already in the picture that are covered by its bounding polygon

boundary specifies the bounding polygon for an opaque box

construct builds a partial picture on a separate ``sheet of paper''

draw adds the contents of the named constructed box to the current picture

Ideal expects all components of a picture to be specified as boxes; instructions to draw the entire picture should comprise a box called ``main.'' Boxes are remembered across .IS-.IE boundaries; if you won't need a box again, you can reclaim the space it requires by including the command `...forget boxname' on a line between any .IS-.IE pair after the last use of boxname. Box main is an exception to this rule: it is always forgotten when the .IE is processed.

During its first pass, ideal solves all the equations to determine the locations of all points it needs to know. These equations must be linear equations in complex variables, although they may include non-linear operators: ideal plugs in for as many variables, and does as much function evaluation, as it can before solving the linear equation. It waits until it has absolutely no hope of reducing an equation to a linear equation before complaining. Ideal knows about the following functions:

.nr 99 \n(.s .nr 98 \n(.f .as 12 "\*(13 .as 12 "\*(13 .as 12 "\|\*(13 .as 12 "\*(13 .as 12 "\|\*(13 .as 11 \*(12 .as 11 " \*(11 .nr 99 \n(.s .nr 98 \n(.f .as 12 "\*(13 .as 12 "\*(13 .as 12 "\|\*(13 .as 12 "\*(13 .as 12 "\*(13 .as 12 "\*(13 .as 12 "\|\*(13 .as 12 "\*(13 .as 12 "\|\*(13 .as 11 \*(12 .as 11 ", .as 11 \*(12 .as 11 " of the way from .as 11 \*(12 .as 11 " to .as 11 \*(12 .as 11 " \*(11

re (z) real part of complex number .nr 99 \n(.s .nr 98 \n(.f .as 11 \*(12 .as 11 " \*(11

im (z) imaginary part of complex number .nr 99 \n(.s .nr 98 \n(.f .as 11 \*(12 .as 11 " \*(11

conj (z) complex conjugate of complex number .nr 99 \n(.s .nr 98 \n(.f .as 11 \*(12 .as 11 " \*(11

abs (z) absolute value (modulus) of complex number .nr 99 \n(.s .nr 98 \n(.f .as 11 \*(12 .as 11 " \*(11

cis (x) .nr 99 \n(.s .nr 98 \n(.f .as 11 "a unit vector in the direction of the real part of its argument .as 11 \*(12 .as 11 ", \*(11 which is an angle in degrees (radians if the line `...radians' appeared more recently in the file than the line `...degrees')

E (x) .nr 99 \n(.s .nr 98 \n(.f .as 12 "\*(13 .as 12 "\|\*(13 .as 12 "\*(13 .as 12 "\*(13 .as 12 "\|\*(13 .as 11 \*(12 .as 11 " \*(11 .nr 99 \n(.s .nr 98 \n(.f .as 11 "if .as 11 \*(12 .as 11 " is measured in degrees \*(11

int (x) .nr 99 \n(.s .nr 98 \n(.f .as 11 "integer part of the real part of its argument .as 11 \*(12 .as 11 " \*(11

angle (z) .nr 99 \n(.s .nr 98 \n(.f .as 11 "arctangent of .as 12 "\|\*(13 .as 12 "\*(13 .as 12 "\|\*(13 .as 12 "\*(13 .as 12 "\*(13 .as 12 "\|\*(13 .as 12 "\*(13 .as 12 "\|\*(13 .as 11 \*(12 .as 11 " \*(11

During the second pass, ideal draws the picture.

To draw a circle, include the line `...libfile circle' between the .IS and .IE lines, and put the box named circle, giving enough information that the circle can be determined; for instance, give the center and the radius, or give three points through which the circle passes, or give the center and a point on the circle. .nr 99 \n(.s .nr 98 \n(.f .as 11 "The circle has center .as 11 \*(12 .as 11 ", radius .as 11 \*(12 .as 11 ", and passes \*(11 .nr 99 \n(.s .nr 98 \n(.f .as 11 "through .as 11 \*(12 .as 11 ", .as 11 \*(12 .as 11 ", and .as 11 \*(12 .as 11 ". \*(11

To draw an arc, include the line `...libfile arc' between the .IS and .IE lines, and put the box named arc, again giving enough information to determine the arc; for instance, give the center, radius, and starting and ending angles, or give three points on the arc--where to start, where to end, and somewhere in between. .nr 99 \n(.s .nr 98 \n(.f .as 11 "The arc has center .as 11 \*(12 .as 11 ", radius .as 11 \*(12 .as 11 ", \*(11 .nr 99 \n(.s .nr 98 \n(.f .as 11 "starts at point .as 11 \*(12 .as 11 " at angle .as 11 \*(12 .as 11 ", \*(11 .nr 99 \n(.s .nr 98 \n(.f .as 11 "passes through point .as 11 \*(12 .as 11 " at angle .as 11 \*(12 .as 11 ", \*(11 .nr 99 \n(.s .nr 98 \n(.f .as 11 "and ends at point .as 11 \*(12 .as 11 " at angle .as 11 \*(12 .as 11 ". \*(11 .nr 99 \n(.s .nr 98 \n(.f .as 11 "If no .as 11 \*(12 .as 11 " is specified, the arc is drawn counterclockwise \*(11 .nr 99 \n(.s .nr 98 \n(.f .as 11 "from .as 11 \*(12 .as 11 " to .as 11 \*(12 .as 11 ". \*(11

The picture will be scaled to a default width of four inches and centered in a column of six inches. The default width can be changed by a `...width' command, which includes a number in inches. The default column width can be changed by a `...colwid' command. To defeat \f2ideal's notion of the size of the picture, you can include lines of the form `...minx', `...miny', `...maxx', or `...maxy'; these give the various coordinates of the bounding box of the picture in the coordinate system used by the picture.

Ideal supports both C-style comments (between /* and */ brackets, and they nest), and shell-style comments (between # and newline).

"SEE ALSO"
C. J. Van Wyk, "IDEAL User's Manual", C. J. Van Wyk.
BUGS
Ideal is relatively unforgiving about syntax errors. Bounding box computation is naive for arcs and text strings.