| utilities {knotR} | R Documentation |
Various utilities for knots
Description
Various utilities for knots including reading files and creating objects
Usage
controlpoints(x)
inkscape(x)
minobj(x)
knotvec(x)
make_controlpoints_from_ink(a)
make_minobj_from_ink(a)
make_minobj_from_vector(vec)
make_ink_from_minobj(x)
make_inkscape_from_controlpoints(b)
make_minobj_from_knot(k)
make_knotvec_from_minobj(x)
Arguments
x |
Suitable object for coercion; see details |
a |
An |
b |
A controlpoints object |
k |
An object of class knot |
vec |
A vector of reals |
Details
Functions inkscape(), minobj(), and knotvec() are
low-level functions; these are the only places that objects have their
classes assigned directly. These functions are not user-friendly and
require very specific types of object; they perform some checks but
are not really intended for the user. Functions as.foo() are
much more user-friendly, and are documented at as.Rd.
Functions make_foo_from_bar() coerce bar objects into
foo objects. Functions that involve symmetry are documented at
symmetry.Rd.
Objects of class inkscape are in the form of a two-column
matrix, with rows corresponding to 2D positions. The rows correspond
to the (x,y) coordinates of points as held in the inkscape file.
There is quite a lot of redundancy in an inkscape object:
The first row of an inkscape object is equal to the last row (this follows from the fact that the path is closed).
If
n=0modulo 3, thena[n+2,]-a[n+1,]==a[n+1,]-a[n], corresponding to the fact that the handles are symmetric in inkscape. This is visualised best byknotplot2(k4_1,ink=TRUE,seg=TRUE)
Look at functions make_inkscape_from_minobj() and
make_minobj_from_ink() to see this from a symbolic
perspective. The vignette also gives some details.
The minobj class is a ‘MINimal OBJect’.
Objects of class minobj are a list of two elements:
$node and $handle_A. Each element has rows
corresponding to 2D positions, the same as inkscape objects.
Element $node shows the positions of the nodes, and element
$handle_A shows the positions of (one of) the handles; the
other handle is symmetrically positioned with respect to its node.
Use knotplot2(k4_1,node=TRUE,seg=TRUE) to see the meaning of
the entries; the nodes are indicated by a square and the handles by
circles.
NB: objects of class minobj have no redundancy in the
sense that changing any entry of either $node or
$handle_A results in modifying the corresponding inkscape
diagram. However, doing this to a knot which has imposed symmetry
conditions (ie a nontrivial symobj) may introduce asymmetry
into the inkscape diagram. For example, one might take a
minobj object whose knot diagram is left-right mirror symmetric
(eg k6_2) and alter one of the handle positions. Then the
resulting inkscape object will be asymmetric. There is an example
using k6_2 below.
An object of class controlpoints is a list of matrices of size
4-by-2. For each matrix, the four rows correspond to the points in 2D
Cartesian space needed to specify a Bezier curve; further details and
examples are given in bezier.Rd. There is lots of redundancy
in a controlpoints object because the inkscape nodes are
symmetric nodes with diametrically opposed handles.
The knotvec class is a named vector of independent
reals suitable for use with optimization routines.
None of the functions here deal with symmetry relations. This is
documented at symmetry.Rd.
Author(s)
Robin K. S. Hankin
See Also
Examples
a <- as.minobj(k6_3)
plot(a$node,asp=1,pch=16)
segments(x0=a[[1]][,1],y0=a[[1]][,2],x1=a[[2]][,1],y1=a[[2]][,2],
main="handle direction follows the string path")
points(getstringpoints(a),type='l',col='gray',lwd=0.4)