readBezierControlPoints: Reads a file of Bezier control points

View source: R/readBezierControlPoints.R

readBezierControlPointsR Documentation

Reads a file of Bezier control points

Description

Reads Bezier control points from a file or files into a list grouped first by curve name and then by the index of the file from which they were read. A separate function from the standard read functions is necessary since the number of control points may differ for each Bezier curve or spline and, thus, the number of values may differ by row.

Usage

readBezierControlPoints(file, ndim = 2, ...)

Arguments

file

file(s) to be read.

ndim

the number of dimensions of the Bezier curve points

...

further arguments to be passed to readLines().

Details

The rows of each file must start with the name of the curve or spline followed by the control points, all separated by tabs. The control points are listed first by dimension and then by point (x1\ty1\tx2\ty2 etc.). For example, three Bezier points starting with [100, 200] would be on one line as follows, with \t replaced by tabs.

tomium_R\t100\t200\t300\t100\t400\t300

Each Bezier curve or spline is first grouped into a list by curve name (e.g. list$tomium_R) and then by the index of the file from which it was read (e.g. list$tomium_R[[1]] from the first file). The control points are made into a matrix where the number of columns corresponds to ndim. The Bezier list structure is similar to the landmark list structure created by readLandmarksToList and can be used to generate points along a Bezier curve or spline. See the R package bezier for more details.

Value

a list of Bezier control points grouped by name and file number.

Author(s)

Aaron Olsen

See Also

readLandmarksToArray, readCheckerboardsToArray, readLandmarksToList,

readLandmarksToMatrix

Examples

## GET FILE DIRECTORY FOR PACKAGE FILES
fdir <- paste0(path.package("StereoMorph"), "/extdata/")

## FILE TO READ
file <- paste0(fdir, "bezier_control_points_a2_v", 1:2, ".txt")

## FILE TO READ
bcp <- readBezierControlPoints(file=file)

aaronolsen/StereoMorph documentation built on June 2, 2022, 4:09 a.m.