There are various ways of declaring and initializing
simplest is to use the constructor taking two
Point A; Point B(2, 2); Path p(A, B); p.draw();
Paths created in this way are important, because they are
guaranteed to be linear, as long as no operations are performed on them
that cause them to become non-linear.
Paths can be used to find intersections.
See Path Intersections.
Paths can be declared and initialized using a single connector
and an arbitrary number of
Points. The first argument is a
string specifying the connector. It is followed by a
bool, indicating whether the
Path is cyclical or not. Then, an arbitrary number of
Point follow. The last argument must be 0.1
Point p; p.shift(1); p.set(1, 2, 2); p.set(1, 0, 2); Path pa("--", true, &p, &p, &p, 0); pa.draw();
Another constructor must be used for
more than one connector and an arbitrary number of
The argument list starts with a pointer to
Point, followed by
string for the first connector. Then,
Point arguments alternate with
for the connectors.
Again, the list of arguments ends in 0. There is no
need for a
bool to indicate whether the
Path is cyclical
or not; if it is, the last non-zero argument will be a connector,
otherwise, it will be a pointer to
Point p; p.set(-2); p.set(2); p.set(0, 0, -2); p.set(0, 0, 2); p = p.mediate(p); p = p.mediate(p); p = p.mediate(p); p = p.mediate(p); p *= p *= p *= p.shift(0, 1); Path pa(&p, "..", &p, "...", &p, "..", &p, "...", &p, "..", &p, "...", &p, "..", &p, "...", 0); pa.draw();
As mentioned above (see Accuracy), specifying connectors is
problematic for three-dimensional
because MetaPost ultimately calculates the "most pleasing curve"
based on the two-dimensional points in the MetaPost code written by
For this reason, it's advisable to avoid specifying
tension or control points in connectors.
Points a (3DLDF)
Path or other object contains,
the less freedom MetaPost has to determine the (MetaPost)
So a three-dimensional
other object in 3DLDF should have enough
Points to ensure
satisfactory results. The
Path in [the previous figure]
really have enough
Points. It may require some trial and error
what a sufficient number of
Points is in a given case.
Paths are very flexible, but not always convenient. 3DLDF
provides a number of classes representing common geometric
Shapes, which will be described in subsequent sections, and I
intend to add more in the course of time.
It's easy to forget to use
Point* arguments, rather
Point arguments, and to forget to end the list of
arguments with 0. If plain
Point arguments are used, compilation
fails with GCC. With the DEC compiler, compilation succeeds, but a
memory fault error occurs at run-time. If the argument list doesn't end
in 0, neither compiler signals an error, but a memory fault error always
occurs at run-time.
Knuth, The METAFONTbook, Chapter 14, p. 127.