metapost (version 1.0-6)

knot: Create a MetaPost Path

Description

These functions can be used to describe a MetaPost path, consisting of two or more knots, with various constraints on how the path behaves between the knots.

Usage

knot(x, y, units = getOption("metapost.units"),
     dir = NA, dir.left = dir, dir.right = dir,
     cp.left.x = NA, cp.right.x = NA, cp.left.y = NA, cp.right.y = NA,
     curl.left = NA, curl.right = NA,
     tension.left = NA, tension.right = NA)
cp(x, y, units = getOption("metapost.units"))
curl(x)
cycle()
dir(x, y = NULL)
tension(x)

Arguments

x

Numeric value: a location (for knot and cp), or an angle (for dir, if y is NULL), or a vector component (for dir), or a curl or tension value. Or a grid unit (for knot and cp).

y

Numeric value: a location (for knot and cp), or a vector component (for dir). Or a grid unit (for knot and cp).

units

The grid coordinate system to use for locations (if locations are only given as numeric values).

dir, dir.left, dir.right

A numeric angle.

cp.left.x, cp.right.x, cp.left.y, cp.right.y

A numeric location.

curl.left, curl.right

A numeric curl value (must be at least 0).

tension.left, tension.right

A numeric tension value (must be at least 3/4). A negative values indicates a lower bound.

Value

The individual functions generate knots and connectors, but when combined together, they produce a MetaPost path ("mppath") object.

Details

A MetaPost path is constructed using calls to knot and combining the results using the + operator (see the examples below).

Constraints for a knot can be specified within the call to knot or by combining connectors (cp, dir, etc) with a knot using +.

Knots can also be combined using - (a straight line rather than a curve), %+% (no inflection), and %-% (straight line with smooth connection) operators.

References

Hobby, J. D. and the MetaPost development team (2018). METAPOST a user's manual. https://www.tug.org/docs/metapost/mpman.pdf

See Also

metapost, mpost, mptrace, grid.metapost.

Examples

# NOT RUN {
knot(0, 0, dir.right=0)
knot(0, 0, dir.right=0) + knot(1, 1)
knot(0, 0) + dir(0) + knot(1, 1)
# }