Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/root/sys/lib/texmf/tex/latex/misc/curves.tex

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


 % To LaTeX this file requires curves.sty in the default or 
 % a texinputs directory.
 % Requires 55000 word of TeX main memory.
  \documentstyle[curves]{article}
  \newcommand{\version}{1.41} 
  \pagestyle{headings}
  \begin{document}
  \title{Curves in \LaTeX\ Pictures\\
  A Manual for {\tt CURVES.STY} and {\tt CURVESLS.STY}\\Version \version}
  \author{Ian Maclaine-cross\thanks{Current Internet address: {\tt
ian@ilm.mech.unsw.edu.au}}\\
 \small  School of Mechanical and Manufacturing Engineering\\ 
  \small  The University of New South Wales\\ 
  \small Sydney Australia 2052} 
  \date{22nd August 1995} 
  \maketitle
  \thispagestyle{empty}
  \tableofcontents
  \section{Introduction}
 
 The picture environment in the \LaTeX \footnote{Leslie Lamport, {\sl
\LaTeX\ A Document Preparation System 2nd ed.,} Addison-Wesley, 1994.} macro
package for \TeX \footnote{Donald E. Knuth, {\sl The \TeX book,}
Addison-Wesley, 1984.}  allows simple line drawing using
characters. These characters include quadrant circular arcs, solid
disks with diameters from 1 to 15pt\footnote{A printer's point,
abbreviated pt, is approximately 0.351460 mm.}  and short lines with a
limited range of slopes in two thicknesses.  A \verb?\begin{picture}?
command defines an area where following commands place these
characters to draw a \LaTeX\ picture. 

  \LaTeX\ pictures save disk space for source descriptions and
computer time in producing documents compared with printer commands or
bit mapped graphics.  From initial pencil sketch on squared graph
paper to final printout, they take half the time for manual pen
drawings. The labor savings are higher for revisions and
rewrites. Unfortunately standard \LaTeX\ cannot yet draw curves like a
pen, compass and French curves can.

  Superimposing characters closely can draw any curve. Disks give directional
independence of line thickness and visual smoothness at large pitch.
Smoothness increases with output resolution but is almost independent of disk
pitch below a critical maximum. The following table suggests this maximum
varies from 0.34pt for an 0.5pt thick curve to 3pt for a 15pt curve.
  \begin{center}
  \setlength{\unitlength}{1pt}
  \begin{tabular}{cccc}
  Thickness & \makebox[3em][l]{Magnified} & Comments & Line at 1/6 slope \\
  \hline
  15pt     &  $\times1$    & 1pt pitch disks&
   \begin{picture}(80,20)(0,15) \linethickness{15pt}
   \renewcommand{\diskpitchstretch}{0.33} \curve(10,15, 70,25)
   \end{picture} \\
  15pt     &  $\times1$    & 3pt pitch disks&
  \begin{picture}(80,20)(0,15)  \linethickness{15pt} \curve(10,15, 70,25)
   \end{picture} \\
  $\approx$0.5pt     &  $\times1$    & \LaTeX\ \verb?\line(6,1)? &
   \begin{picture}(80,20)(0,15) \thinlines \put(10,15){\line(6,1){60}}
   \end{picture} \\
  $\approx$0.5pt     &  $\times1$    & 0.34pt pitch disks &
   \begin{picture}(80,20)(0,15) \thinlines
  \curve(10,15, 70,25)
   \end{picture} \\
  $\approx$0.5pt     &  $\times30$ \rule[-10pt]{0pt}{10pt}   &
\parbox{8em}{\centering 0.34pt pitch disks\\ resolution $\times30$ } &
   \begin{picture}(80,20)(0,15) \multiput(10,15)(10.2,1.7){7}{\circle*{15}}
   \end{picture} \\
  \hline
  \end{tabular}
  \end{center}

  \LaTeX\ \verb?\line?\footnotemark[1] or line drawing \verb?\special?
commands require a tenth the \TeX\ memory so are preferable to disks if
available. A smooth curve may require thousands of disks or hundreds of lines.
\LaTeX\ can load \TeX\footnote{Donald E. Knuth, {\sl The \TeX book,}
  Addison-Wesley, 1984, Chapter 20.} macros from style files with a
\verb?.sty? extension. These macros can calculate the disk or line positions
for a curve.

  {\tt curves.sty} provides macro commands for drawing curves using disks.
Version \version\ loads in about 2500 words\footnote{A character or token
takes a \TeX\ word, 32 bits or larger.} of \TeX's main memory, which allows a
small \TeX. Complex or numerous floating drawings still require a big \TeX\
with {\tt curves.sty}. {\tt curvesls.sty} uses fewer disks and line drawing
\verb?\special?s for increased speed and a tenth the \TeX\ memory.

  The capabilities of these macros are:---
    \begin{itemize}
  \item A compatible replacement for \verb?\bezier?\footnote{See your Local
Guide. Try the system command {\tt latex local} to get a \LaTeX ed Guide.} 
from {\tt bezier.sty} or {\tt LaTeX2e}. 
  \item Work with {\makeatletter \@ifundefined{SLiTeX}{\tt SLiTeX}{\SLiTeX}}
for overhead transparencies and {\tt LaTeX2e}\footnote{Michel Goossens, Frank
Mittelbach and Alexander Samarin, {\sl The \LaTeX\ Companion,} Addison-Wesley,
1994.} 
  \item Curves have the minimum number of disks or straight lines for visual
smoothness.
  \item Curve thickness adjustable from 0.5 to 15pt (0.17 to 5mm).
  \item Curves have continuous slope.
  \item Curves for any number of points greater than one using \verb?\curve?.
  \item Control of end slopes using \verb?\tagcurve?.
  \item Closed curves with continuous slope using \verb?\closecurve?.
  \item Large circles \verb?\bigcircle? and circular arcs \verb?\arc?.
  \item Independent scaling of curve abscissa and ordinates to fit graphs.
  \item Affine scaling for making arcs or circles elliptical.
  \item Symbols and dash patterns combined without interference.
  \item Any dash length or spacing.
  \item Three methods for fitting dash patterns to curves.
    \end{itemize}

  Parabolas approximate the segments between the specified coordinate points.  
At an internal point, the slope of the parabolas joining from either side is 
the same as the straight line joining the points on either side. For an end 
segment, the inside point of the parabola is made a vertex which determines 
the slope of the end point. \verb?\tagcurve? has hidden end segments which 
allows complete control of slope at the visible end point when desired. 
  
  The four points at the end and adjacent to a segment may make a parabola 
inappropriate. The points could be close to a straight line or consistent with 
an inflexion point.  A straight line then replaces the parabola and optionally 
a warning is issued. 

The parabolas are drawn as a series of short straight line segments.
For {\tt curvesls.sty}, the dvi driver draws the straight lines as instructed 
by \verb?\special? commands. For {\tt curves.sty}, the straight lines are 
drawn as overlapping disks at high speed using a simple tail chasing macro. 
This macro's arithmetic calculations are two fixed point additions per disk 
drawn. 

The \TeX\ arithmetic in {\tt curves.sty} for the initial differences
between disk positions gives an error of less than 0.005\% at the
segment end. Even for a segment 1000pt long, this is less than 0.05pt and the 
resolution of most output devices. Errors are sometimes slightly larger 
between coordinates but you can reduce them if necessary by specifying more 
coordinates. 

  For circles and circular arcs, a parabola approximates an arc segment no
more than 23$^\circ$ giving a radius increase between segment ends less than
0.02\%. The error in computing and multiplying by sine and cosine is usually
less than 0.01\% of the radius at the far end of an arc.

  Brief descriptions, simple examples and a command summary follow. They
presume familiarity with relevant chapters of the \LaTeX\
manual\footnotemark[1].

  \section{Installation}

  Name either {\tt curves} or {\tt curvesls} in the \verb?\usepackage?
command at the top of your main {\tt .tex} file {\it e.g.\/,}
  \begin{verbatim}
  \documentclass[11pt]{article}
  \usepackage{curves}
  \end{verbatim}
  {\tt curves.sty} or {\tt curvesls.sty} should be in the default or a {\tt
texinput} directory. For the older \LaTeX\ 2.09 name them in the
\verb?\documentstyle? command.

  Do not combine {\tt curves} or {\tt curvesls} with {\tt bezier} in this
command. They contain a fast powerful replacement for \verb?\bezier?.
Drawings using \verb?\bezier? should not change their appearance.

  \newcommand{\PiCTeX}{\relax P\kern-.10em\lower.4ex\hbox{I}\kern
    -.10em\/C\kern-0.15em\TeX}
  \PiCTeX\footnote{Michael J. Wichura, {\sl The \PiCTeX\ Manual,} Chicago,
1987, available from \TeX\ Users' Group.} is a large set of \TeX nical drawing
macros for plain \TeX\ which \LaTeX\ pictures can also use. \PiCTeX\ requires
a big \TeX. I have not checked compatibility with {\tt curves} or {\tt
curvesls} because I do not use \PiCTeX.
   \renewcommand{\PiCTeX}{}

  {\tt curvesls.sty} uses line drawing \verb?\special?s to reduce required
memory and increase speed. As originally supplied it uses the \verb?\special?s
of em\TeX\ by Eberhard Mattes for IBM PC compatibles. em\TeX\ is available 
from CTAN\footnote{Directory {\tt /tex-archive/systems/msdos/emtex} at {\tt 
ftp.shsu.edu} for example.} and the \TeX\ Users' Group. The em\TeX\ 
\verb?\special?s are also available for Tomas Rokicki's {\tt dvips}. If you 
use {\tt dvips}, ask if they have been compiled in.  To use other line drawing 
  \verb?\special?s substitute them at {\tt curvesls.sty}'s start. Your system 
guru may do this for you. You can test {\tt curvesls.sty} after substituting 
\verb?\special?s, by replacing {\tt curves} with {\tt curvesls} in this file's 
\verb?\documentstyle? command. This file looks the same \LaTeX ed with either 
{\tt curves} or {\tt curvesls}. 

   A drawing frequently uses auxiliary commands to size, place, label and
caption it. The following commands draw the box in Figure~\ref{box} on
page~\pageref{box}:

  \begin{figure}
  \begin{center}
  \setlength{\unitlength}{1mm}
  \begin{picture}(100,50) \large\sf
  \linethickness{1mm}
  \put(20,5){\framebox(60,40){BOX}}
  \end{picture}
  \end{center}
  \caption{This is a box.}
  \label{box}
  \end{figure}

  \begin{verbatim}
  \begin{figure}
  \begin{center}
  \setlength{\unitlength}{1mm}
  \begin{picture}(100,50) \large\sf
  \linethickness{1mm}
  \put(20,5){\framebox(60,40){BOX}}
  \end{picture}
  \end{center}
  \caption{This is a box.}
  \label{box}
  \end{figure}
  \end{verbatim}
  Lamport\footnotemark[1] explains these commands. This example is for those
unfamiliar with the \LaTeX\ picture environment. The following examples avoid
the {\tt figure} environment but it is often essential.

  \section{Curves}
  \label{curves}
  The curve drawing commands, \verb?\curve?, \verb?\closecurve? and
\verb?\tagcurve?, draw parabola segments between coordinate points in the
argument. The segments' tangents at these points are parallel to each other
and to straight lines through the points either side. Segments at curve ends
are from parabolas through the last three points. \verb?\closecurve? adds a
parabola between end points to close the curve. \verb?\tagcurve? omits the
first and last segments drawing curves with end tangents specified. The
following table shows these features.

  \begin{center}
  \setlength\unitlength{0.4pt}
  \linethickness{0.7mm}
  \begin{tabular}{lc}
  Example & Curve \\
  \hline
  \raisebox{60\unitlength}{\tt\char92 curve(0,0, 50,100, 100,0)} &
  \begin{picture}(100,120)(0,-10)
  \curve(0,0, 50,100, 100,0)
  \end{picture}\\
  \raisebox{80\unitlength}{\tt\char92 closecurve(0,0, 50,100, 100,0)} &
  \begin{picture}(100,170)(0,-60)
  \closecurve(0,0, 50,100, 100,0)
  \end{picture} \\
  \raisebox{60\unitlength}{
    \tt\char92 tagcurve(100,0, 0,0, 50,100, 100,0, 0,0)} &
  \begin{picture}(120,120)(-10,-10)
  \tagcurve(100,0, 0,0, 50,100, 100,0, 0,0)
  \end{picture} \\
  \hline
  \end{tabular}
  \end{center}

  Axial flow fans often use the RAF 6E aerofoil section. The section
coordinates in the following macro come directly from aerodynamic
tables\footnote{R.A. Wallis, {\sl Axial Flow Fans,} Academic Press, 1961,
p.335}. The \verb?\arc? commands draw the leading and trailing radii and the
two coordinate \verb?\curve? the flat chord.
  \begin{verbatim}
  \newcommand{\RAFsixE}{
    \scaleput(1.25,1.25){\arc(0,-1.25){-135}}
    \scaleput(0,0){\curve(0.366,2.133, 1.25,3.19, 2.5,4.42,
      5.0,6.10, 7.5,7.24, 10,8.09, 15,9.28, 20,9.90, 30,10.3,
      40,10.22, 50,9.80, 60,8.98, 70,7.70, 80,5.91, 90,3.79,
      95,2.58, 99.24,1.52)}
    \scaleput(99.24,0.76){\arc(0,-0.76){180}}
    \scaleput(0,0){\curve(1.25,0, 99.24,0)}
    }
  \end{verbatim}
  \newcommand{\RAFsixE}{
  \scaleput(1.25,1.25){\arc(0,-1.25){-135}}
  \scaleput(0,0){\curve(0.366,2.133, 1.25,3.19, 2.5,4.42,
    5.0,6.10, 7.5,7.24, 10,8.09, 15,9.28, 20,9.90, 30,10.3,
    40,10.22, 50,9.80, 60,8.98, 70,7.70, 80,5.91, 90,3.79,
    95,2.58, 99.24,1.52)}
  \scaleput(99.24,0.76){\arc(0,-0.76){180}}
  \scaleput(0,0){\curve(1.25,0, 99.24,0)}
  }
  In a picture environment like:
  \begin{verbatim}
  \begin{picture}(100,20)
    \RAFsixE
  \end{picture}
  \end{verbatim}
  this macro draws:
  \linethickness{0.7mm}
  \setlength\unitlength{0.5mm}
  \begin{center}
  \begin{picture}(100,20)
    \RAFsixE
  \end{picture}\\
  The RAF 6E has a flat undersurface.
   \end{center}

  The drawing command \verb?\bigcircle? works similarly to \verb?\circle?
except there is no \verb?\circle*? equivalent. The following section scales it
to an ellipse.

  \section{Scaling}
  The size of \LaTeX\ picture objects may be uniformly scaled by preceding
them with:
  \begin{verbatim}
  \setlength{\unitlength}{x\unitlength}
  \end{verbatim}
  where {\tt x} the desired scale factor is a decimal number.

  The \verb?\scaleput?s in \verb?\RAFsixE? position the curves using the scale
factors \verb?\xscale?, \verb?\xscaley?, \verb?\yscale? and \verb?\yscalex?.
The drawing commands use the same scale factors. {\tt curve} initially sets
these scale factors to 1, 0, 1 and 0 respectively. \verb?\renewcommand? may
reset them to any decimal number. These factors can rotate pictures. The
factors following rotate the RAF~6E through 12$^\circ$ clockwise about its
{\tt (0,0)} co-ordinate:
  \begin{verbatim}
  \renewcommand{\xscale}{0.9781}
  \renewcommand{\xscaley}{0.2079}
  \renewcommand{\yscale}{0.9781}
  \renewcommand{\yscalex}{-0.2079}
  \put(0,20){\RAFsixE}
  \end{verbatim}
  This draws:
  \begin{center}
  \begin{picture}(120,30)(-20,0)
  \renewcommand{\xscale}{0.9781}
  \renewcommand{\xscaley}{0.2079}
  \renewcommand{\yscale}{0.9781}
  \renewcommand{\yscalex}{-0.2079}
  \put(0,20){\RAFsixE}
  \thicklines
  \put(-20,5){\vector(1,0){20}}
  \end{picture}

  The RAF 6E has maximum lift at angles of attack over 12$^\circ$.
  \end{center}
  Note that \(\cos12^\circ\approx0.9781\) and \(\sin12^\circ\approx0.2079\)
  \let\RAFsixE\relax


  Axonometric projection is another scaling application. Circles become
ellipses and circular arcs become elliptical arcs. The commands drawing the
ellipse and arc in the following washer are:
  \begin{verbatim}
  \put(20,5){
    \renewcommand{\xscale}{1}
    \renewcommand{\xscaley}{-1}
    \renewcommand{\yscale}{0.6}
    \renewcommand{\yscalex}{0.6}
    \scaleput(10,10){\bigcircle{10}}
    \put(0,-2){
      \scaleput(10,10){\arc(5,0){121}}
      \scaleput(10,10){\arc(5,0){-31}}
      }
    }
  \end{verbatim}
  {\tt (20,5)} are the drawing coordinates of the upper vertex of the washer
closest to the reader. The angles for the \verb?\arc?s were found by trial and
error.
  \begin{center}
  \setlength\unitlength{1mm}
  \begin{picture}(40,30)
  \thicklines
  \multiput(20,5)(20,12){2}{\line(0,-1){2}\line(-5,3){20}}
  \multiput(20,5)(-20,12){2}{\line(5,3){20}}
  \put(20,3){\line(5,3){20}}
  \put(20,3){\line(-5,3){20}}
  \put(0,15){\line(0,1){2}}
  \linethickness{1pt}
  \put(20,5){
    \renewcommand{\xscale}{1}
    \renewcommand{\xscaley}{-1}
    \renewcommand{\yscale}{0.6}
    \renewcommand{\yscalex}{0.6}
    \scaleput(10,10){\bigcircle{10}}
    \put(0,-2){
      \scaleput(10,10){\arc(5,0){121}}
      \scaleput(10,10){\arc(5,0){-31}}
      }
    }
  \end{picture}

  Square washers are sometimes preferred for soft materials.
  \end{center}

      \section{Symbols}
      \label{symbols}

  {\tt curves} can also place symbols. \verb?\curvesymbol? must first define
the symbol as anything a \verb?\put? or \verb?\multiput? may draw. A negative
symbol count between drawing command and coordinates {\it e.g.,}
\verb?\tagcurve[-3](0,100,...)? fixes the number of symbols per curve segment.

  These commands draw flight times and successive positions in the following
drawing:
  \begin{verbatim}
  \newcounter{time}
    \curvesymbol{\thetime\,s\addtocounter{time}{1}}
    \put(5,4){\curve[-2](0,0, 9.8,19.6, 19.6,0)}
    \curvesymbol{\phantom{\circle*{1}}\circle*{1}}
    \put(5,2){\curve[-2](0,0, 9.8,19.6, 19.6,0)}
  \end{verbatim}
  where \verb?\phantom? is a plain \TeX\ command from the \TeX
book\footnotemark[2].
  \begin{center}
  \setlength\unitlength{2mm}
  \begin{picture}(40,35)(-5,-5) \sf
  \thicklines
  \newcounter{time}
    \curvesymbol{\thetime\,s\addtocounter{time}{1}}
    \put(5,4){\curve[-2](0,0, 9.8,19.6, 19.6,0)}
    \curvesymbol{\phantom{\circle*{1}}\circle*{1}}
    \put(5,2){\curve[-2](0,0, 9.8,19.6, 19.6,0)}
  \put(0,0){\vector(0,1){28}}
  \put(0,0){\vector(1,0){30}}
  \multiput(5,0)(5,0){5}{\line(0,1){1}}
  \multiput(0,5)(0,5){5}{\line(1,0){1}}
  \setcounter{time}{0}
  \multiput(0,-1)(5,0){6}{\makebox(0,0)[t]{\thetime}\addtocounter{time}{5}}
  \put(28,-1){\makebox(0,0)[tl]{$x$ (m)}}
  \setcounter{time}{0}
  \multiput(-1,0)(0,5){6}{\makebox(0,0)[r]{\thetime}\addtocounter{time}{5}}
  \put(-1,27){\makebox(0,0)[rb]{$y$ (m)}}
  \end{picture} \\
  Successive positions of a sphere with initial position $(5,2)$ m,\\ initial
velocity $(4.9,9.8)$ m/s, and acceleration $(0,-9.8)$ m/s$^2$. \\
  The flight time is recorded above each sphere position.
  \end{center}

  Fixed spacing of symbols at lengths other than the segment's requires more
commands. Empty \verb?\curvedashes?, empty \verb?\curvesymbol? and negative
symbol count stops drawing so a drawing command will calculate
\verb?\curvelength? only. \verb?\curvesymbol? then resets the symbol and
\verb?\curvedashes? sets the spacing to its pattern length. If there are no
symbols at the ends, \verb?\overhang? pulls symbols along the curve. The last
command with no symbol count draws the symbols.

   \verb?\arc? and \verb?\bigcircle? use sixteen segments for a circle so if
eight symbols are required the fixed spacing technique is necessary. The
following commands draw the pin numbers on a relay base:

  \begin{verbatim}
    \newcounter{pin}
    \curvedashes{}
    \curvesymbol{}
    \put(60,60){\arc[-1](40,0){-360}}
    \setlength{\curvelength}{0.125\curvelength}
    \curvedashes[\curvelength]{1}
    \setlength{\overhang}{0.5\curvelength}
    \curvesymbol{\addtocounter{pin}{1}\thepin}
    \put(60,60){\arc(40,0){-360}}
  \end{verbatim}

  \begin{center}
  \setlength\unitlength{0.3mm}
  \begin{picture}(120,120)  \sf
  \thicklines
  \linethickness{1pt}
    \curvedashes{}
    \curvesymbol{}
  % base
    \put(60,60){\bigcircle{100}}
  % spigot
    \put(60,60){\arc(10,3){325}\put(10,0){\arc(0,3){-180}}}
  % pins
    \put(60,60){\bigcircle[-1]{60}}
    \setlength{\curvelength}{0.125\curvelength}
    \curvedashes[\curvelength]{1}
    \overhang0.5\curvelength
    \curvesymbol{\phantom{\circle{5}}\circle{5}}
    \put(60,60){\bigcircle{60}}
  % pin numbers
    \newcounter{pin}
    \curvedashes{}
    \curvesymbol{}
    \put(60,60){\arc[-1](40,0){-360}}
    \divide\curvelength8
    \curvedashes[\curvelength]{1}
    \setlength{\overhang}{0.5\curvelength}
    \curvesymbol{\addtocounter{pin}{1}\thepin}
    \put(60,60){\arc(40,0){-360}}
  \end{picture} \\
  The pin numbering of plug-in relays is clockwise \\
  from the spigot key when viewed from below.
  \end{center}

  If symbols and dash pattern exist and \verb?\overhang? is 0pt, \verb?curves?
draw the first position blank. For equal spacing they draw the last position
blank if rounding error causes the last pattern to be slightly short. If
\verb?\renewcommand? changes \verb?\diskpitchstretch?, rounding error changes
and the final symbol may reappear. To avoid fiddling with
\verb?\diskpitchstretch? for closed curves with symbols equally spaced, use an
\verb?\overhang? which is a fraction of a pattern length as in the previous
example.

  \section{Dashes}

  \verb?\curvedashes? must first define a dash pattern with length greater
than 0pt. Many symbol and pattern combinations are possible. The fixed number
and fixed spacing methods of symbol drawing described in Section~\ref{symbols}
work with three methods of drawing dashes which are:
  \begin{enumerate}
  \item if there is no symbol count and no symbol, a dash pattern with its
length reduced by \verb?\csdiameter? is drawn between symbols spaces of width
close to \verb?\csdiameter? to give an overall spacing equal to the pattern
length specified by the \verb?\curvedashes? command;
  \item if there is a symbol count but no symbol, the dash patterns drawn have
their length equal to that defined by \verb?\curvedashes? with
\verb?\csdiameter? gaps at symbol positions;
  \item if there is a symbol count and a symbol, the dash patterns drawn have
their length adjusted slightly so an integral number of patterns fit between
symbol positions.
  \end{enumerate}

  Dash pattern commands for centrelines\footnote{R.N. Roth and I.A. van
Haeringen, {\sl The Australian Engineering Drawing Handbook, Part~1 Basic
Principles and Techniques,} The Institution of Engineers, Australia, Canberra,
1986.} follow for the three techniques above in order:
  \begin{verbatim}
  \linethickness{0.25mm}
  \curvedashes[1.2mm]{0,8,1,3,1,8}
  \settowidth{\csdiameter}{00}
  \put(0,20){\curve(0,0, 30,5, 60,0)}
  \put(0,10){\curve[1](0,0, 30,5, 60,0)}
  \curvesymbol{\thepin\addtocounter{pin}{1}}
  \setlength{\csdiameter}{2\csdiameter}
  \put(0,0){\curve[1](0,0, 30,5, 60,0)}
  \end{verbatim}

 The following figure shows the resulting dash patterns. The upper line has
first position blank because the \verb?\overhang? is 0pt. It has patterns
shrunk to scale between symbol spaces {\it e.g.,}~1 to~2, and symbol space
centres one pattern length apart. The middle line has patterns close to
defined length but with the first dash part blanked by half of symbol space~3
and the second pattern broken in its first dash by symbol space~4. The lower
line patterns are stretched between symbol spaces. Which  pattern is
appropriate depends on picture meaning and function.

  \begin{center}
  \setlength\unitlength{1mm}
  \begin{picture}(60,25) \sf
  \setcounter{pin}{1}
  \linethickness{0.25mm}
  \curvedashes[1.2mm]{0,8,1,3,1,8}
  \settowidth{\csdiameter}{00}
  \put(0,20){\curve(0,0, 30,5, 60,0)}
  \put(0,10){\curve[1](0,0, 30,5, 60,0)}
  \curvesymbol{\thepin\addtocounter{pin}{1}}
  \setlength{\csdiameter}{2\csdiameter}
  \put(0,0){\bezier{-2}(0,0)(30,10)(60,0)}
  \put(0,20){\curve(0,0, 30,5, 60,0)}
  \curvedashes{}
  \put(0,10){\curve[-1](0,0, 30,5, 60,0)}
  \put(0,0){\bezier{-2}(0,0)(30,10)(60,0)}
  \end{picture} \\
  Centrelines and Symbols
  \end{center}

  \section{Errors}
  Syntax errors like incorrect or missing punctuation while using {\tt curves}
will result in \TeX\ or \LaTeX\ error messages. The \TeX book\footnotemark[2]
and \LaTeX\ manual\footnotemark[1] explain the meaning and correction of these
errors. The previous examples and Section~\ref{summary} should make the
correct syntax for {\tt curves} commands clear.

  {\tt curves} will write a {\tt LaTeX error.} message to the screen and {\tt
log} file if you supply an incorrect number of coordinates.

   If four sequential points in a drawing command argument have the line
through the first and third parallel to the line through the second and
fourth:
   \begin{itemize}
  \item exactly or closely, {\tt curves} knows it cannot draw a parabola 
tangent to two parallel lines, issues to the screen and log file:\\ 
  {\tt LaTeX Warning: \string\curve\ straight from \ldots}\\
   and draws a straight line;  
  \item or approximately, {\tt curves} may draw an unexpected curve with no
warning.
   \end{itemize}
      If four sequential points in a drawing command argument have the line
through the first and second parallel to the line through the third and
fourth:
  \begin{itemize}
  \item {\tt curves} draws a parabola which may be nowhere near the curve.
  \end{itemize}
   If the four points were on a straight line, removing one or more points is
a remedy. If they are not on a straight line, adding points may help. 
  Specifying many points will give you a satisfactory curve with perhaps an 
annoying number of \verb?\curve straight? warnings. After a 
\verb?\curvewarnfalse?, {\tt curves} still uses the straight lines but does 
not tell you. 

  Curvature changes sign on curves like \(y=\sin x\). Specifying inflection 
points as {\tt curve} coordinates will reduce error and  specifying sufficient 
coordinates will then give satisfactory results. For discontinuous tangents 
splitting a curve into pieces is unavoidable.  Splitting a curve into pieces 
with curvature the same sign can give satisfactory results with fewer 
coordinates. \verb?\tagcurve? can prevent tangent discontinuities. If an 
inflexion point's exact location is unknown, try the midpoint of the straight
line through the ends of its segment.

  Curves appear rougher than horizontal and vertical lines. Picture
digitization causes this not inaccuracy in \TeX, {\tt curves.sty} or {\tt
curvesls.sty}. Setting \verb?\diskpitchstretch? to a value less than one with
\verb?\renewcommand? may smooth an unusually rough curve.

  Symbols and symbol spaces misaligned are usually due to rounding error.
Adjusting \verb?\diskpitchstretch? below one can reduce rounding error and
increase alignment accuracy. This should be limited to the misaligned curve
with {\tt \{\ \}}\footnotemark[1].

  The replacement \verb?\bezier? does not give exactly the same results as the 
original in {\tt bezier.sty} or in {\tt LaTeX2e}. The difference is extremely 
small but if it is important to you comment out the five lines of code for 
\verb?\bezier? and \verb?\@bezier? near the start of {\tt curves.sty} or {\tt 
curvesls.sty}. You now have a \verb?\bezier? which is slower and needs more 
memory but has only its original capabilities and gives only its original 
results. 
    
Please email me examples of any errors not covered above. You may have found a 
bug in the code or documentation. 
  
\section{Pleas for the Future}

{\tt curves} will never work with plain \TeX\ and it will never be as
powerful as {\sf METAFONT} or importing encapsulated PostScript
files. Suggestions or criticisms by email are 
welcome. Version \version\ has benefitted greatly from previous
help. The latest versions are first available at URL:
 \begin{verbatim}
 ftp://ilm.mech.unsw.edu.au/pub/latex/macros/curves/
 \end{verbatim}
 The IP number is {\tt 149.171.228.99} but use your local CTAN mirror to
reduce Internet load.

{\tt curvesls.sty} uses much less \TeX\ memory and is faster than
{\tt curves.sty}. More people could use {\tt curvesls.sty} if em\TeX\
or equivalent line drawing \verb?\special?s were compiled into dvi
drivers for viewing and printing. Ask your system people for this!

A {\tt .dvi} file containing curves produced with {\tt curvesls.sty}
has many occurrences of the text strings {\tt em:lineto}, {\tt
em:moveto} and {\tt em:linewidth XXXXpt} placed by the em\TeX\
\verb?\special?s. These strings would have earlier occupied \TeX\
memory. Extra space is also taken by the disks {\tt curvesls} uses to
cover the cracks between square line ends at a slight angle. Renaming
these \verb?\special?s to {\tt L}, {\tt M} and {\tt W XXXXpt}
respectively would save \TeX\ memory. Even better, {\tt W XXXXpt}
could also calculate and store the bitmap of a disk which {\tt L}
would add to its line end to round it so {\tt curvesls} need not add
disks to cover cracks. A fourth \verb?\special?, {\tt D}, could place
the disk at the current position which {\tt curvesls} would use to
round the beginning of a curve. If you write dvi drivers, please add
these four proposed \verb?\special?s.


 
  
  \section{Curves Summary} 
  \label{summary}
  The commands following are for the picture environment in the \LaTeX\ 
manual\footnotemark[1].  
  \makeatletter
  % Hanging indentation with paragraph separation for author-date, etc.
  \newenvironment{hanging}{\list{}{\topsep\itemsep \advance\topsep-\parskip
    \parsep\itemsep \itemsep\z@skip \partopsep\parskip
    \ifdim\parindent>\z@ \@tempdimb\parindent \else \@tempdimb1.5 em\fi
    \leftmargin\@tempdimb \listparindent-\@tempdimb \itemindent-\@tempdimb
    \rightmargin\z@ \labelsep\z@ \labelwidth\z@ }\item[]}%
    {\endlist \addvspace\parsep}
  \makeatother


    \subsection{Arguments of Commands}

    \begin{hanging}

{\tt <blank length>} decimal number of {\tt <unit len>} blank. Not negative.

     {\tt <character or symbol>} is anything which a \verb?\put? or
\verb?\multiput? may draw.

    {\tt <coordinates>} are decimal numbers giving alternate $x$ and $y$
  coordinates of the curve as multiples of \verb?\unitlength?, comma
separated.

{\tt <[,dash...]>} optional continuation of alternating dash and blank numbers
of unit lengths, comma separated. Not negative. Allows decimal points.

 {\tt <diameter>} is a decimal number giving the diameter in
  \verb?\unitlength?s.

    {\tt <symbol count>} is the number of symbols or patterns to be drawn,
default 0.

  {\tt <unit len>} unit length dimension {\it e.g.\/,} 2.5mm, 10pt, used in
measuring blanks and dashes. Not negative. Default value is
\verb?\unitlength?.

     \end{hanging}


    \subsection{Lengths used by Commands} 
     \begin{hanging}

     \verb?\csdiameter? is the size of the space left for a symbol and can be
increased or set with \verb?\settowidth{\csdiameter}{<character or symbol>}?.

  \verb?\curvelength? is the total length of the curve calculated before
drawing by using Simpson's rule once between each pair of coordinate points.

\verb?\overhang? length of as drawn dash pattern overlapping start of
patterns.
      \end{hanging}
  \subsection{Control Commands} 
  \begin{hanging}
  \verb?\curvewarntrue? turns warning of parabola replacement by straight 
lines on (default). 
  
  \verb?\curvewarnfalse? turns warning of parabola replacement by straight 
lines off.  
  \end{hanging} 
    \subsection{Parameter Setting Commands} 

     \begin{hanging}
     \verb?\curvesymbol{<character or symbol>}? sets symbol and
  \verb?\csdiameter?.

   \verb?\curvedashes[<unit len>]{<blank length><[,dash...]>}? A drawing
command before a \verb?\curvedashes? or after one with an empty or zero length
pattern will draw:

     \begin{hanging}

  if {\tt <symbol count>} is zero or missing, a continuous curve;

else if {\tt <symbol count>} is positive, {\tt <symbol count>-1} squares of
line thickness size between and additional squares at coordinates or bezier
end points;

else if no {\tt <character or symbol>} exists, nothing;

  else, {\tt -<symbol count>-1} characters or symbols between coordinates and
additional ones at coordinates or bezier end points.

      \end{hanging}
  After a \verb?\curvedashes? command defining a pattern whose length exceeds
zero, commands draw:

     \begin{hanging}

if {\tt <symbol count>} is zero or missing then at a spacing equal to the
specified pattern length,

      \begin{hanging}
  if no {\tt <character or symbol>} exists, a dash pattern reduced in length
by \verb?\csdiameter? to fit between symbol spaces of \verb?\csdiameter?,

  else if \verb?\overhang? is not 0pt, a {\tt <character or symbol>} at all
positions,

  else a {\tt <character or symbol>} with the first position blank;

        \end{hanging}

else, \verb?\csdiameter? wide symbol spaces, one at and
  {\tt |<symbol count>|-1} between coordinate points with dash pattern
lengths,
   \begin{hanging}
   if no {\tt <character or symbol>} exists, exact but broken by the spaces,

else, adjusted to give a whole number of patterns between spaces.
   \end{hanging}
        \end{hanging}


      \verb?\diskpitchstretch? is initially 1 but \verb?\renewcommand? can
change it to a higher value like 5 to save memory in drafts of complex
documents or a lower local value like 0.5 to smooth curve digitization.

      \verb?\linethickness{<len>}? sets line or dash thicknesses to {\tt
<len>} from 0.5pt up to 15pt (0.17mm to 5mm). \verb?\thicklines? and
\verb?\thinlines? also set thickness.

     \verb?\xscale?, \verb?\xscaley?, \verb?\yscale? and \verb?\yscalex? are
scale factors initially set to 1, 0, 1 and 0 respectively which
\verb?\renewcommand? or \verb?\def? can reset.
    \end{hanging}


    \subsection{Curve Drawing Commands}
  Curves drawn consist of parabolic arcs between coordinate points with
tangents at each point parallel to the straight line through adjacent points.

    \begin{hanging}
    \verb?\arc[<symbol count>](X1,Y1){<angle>}? draws a circular arc centred
on current position, starting from {\tt (X1,Y1)} and proceeding
counterclockwise for {\tt <angle>} degrees.

    \verb?\bezier{<symbol count>}(X1,Y1)(X2,Y2)(X3,Y3)? draws a curve through
the end points {\tt (X1,Y1)} and {\tt (X3,Y3)} tangent to the straight lines
joining each of them to {\tt (X2,Y2)}. Extended faster replacement for {\tt
bezier.sty} version.

    \verb?\bigcircle[<symbol count>]{<diameter>}? draws a circle of diameter
equal to {\tt <diameter>} times \verb?\unitlength?.

    \verb?\closecurve[<symbol count>](<coordinates>)? draws a closed curve
with continuous tangents at all points. At least 6 coordinates required.

    \verb?\curve[<symbol count>](<coordinates>)? draws a curve through the
specified {\tt <coordinates>}. For 4 coordinates this is a straight line.

    \verb?\scaleput(X1,Y1){<picture object>}? places a picture object in a
position scaled by \verb?\xscale?, \verb?\xscaley?, \verb?\yscale? and
\verb?\yscalex? for axonometric projection or rotations.

    \verb?\tagcurve[<symbol count>](<coordinates>)? draws a curve without its
first and last segments but if only 6 coordinates draws the last segment only.
      \end{hanging}
   \end{document}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.