edgePoints: Calculate edge points

View source: R/edge.R

edgePointsR Documentation

Calculate edge points

Description

Calculate points on the edge or boundary of a variable-width line.

Usage

edgePoints(x, d, ...)
## S3 method for class 'vwcurveGrob'
edgePoints(x, d, which = c("left", "right"), direction = "forward", debug = FALSE, ...) 
## S3 method for class 'vwlineGrob'
edgePoints(x, d, x0, y0, which = 1, direction = "forward", debug = FALSE, ...) 
## S3 method for class 'vwXsplineGrob'
edgePoints(x, d, which = c("left", "right"), direction = "forward", debug = FALSE, ...)
## S3 method for class 'brushXsplineGrob'
edgePoints(x, d, x0, y0, which = 1, direction = "forward", debug = FALSE, ...) 
## S3 method for class 'offsetXsplineGrob'
edgePoints(x, d, x0, y0, which = 1, direction = "forward", debug = FALSE, ...) 

Arguments

x

A variable-width line grob.

d

A numeric vector or unit specifying locations along the boundary of the variable-width line.

which

For some methods, this is either "left" or "right" (or both) indicating which edge to find locations on. For other methods, this is a numeric, selecting which boundary to find locations on. See Details.

direction

Either "forwards" or "backwards" to indicate the direction of traversal for the edge.

x0, y0

A location used to determine the start point for traversing an edge.

debug

A logical indicating whether to draw graphical debugging information.

...

Additional arguments for methods.

Details

If the distance is numeric, it is assumed to be a proportion of the length of an edge.

What constitutes an edge varies between different methods: some methods produce distinct left and right edges (ignoring line endings), in which case locations can be found on either edge; other methods generally produce a single boundary (including line endings), but self-intersecting lines can produce additional boundaries.

For some methods, it is possible for a boundary to form loops, so an edge location is not guaranteed to be on the external boundary of the variable-width line.

For lines with distinct left and right edges, the forwards direction is the direction of the main curve. For lines with a single boundary, the forwards direction is anticlockwise.

For lines with a single boundary, the start point on the boundary is defined as the nearest point on the boundary to the location specified by x0 and y0.

Value

For methods with a single boundary, a list with components x and y, giving locations on the edge of the variable-width line, and tangent, giving the tangent to the edge at each location.

For methods with distinct left and right edges, a list with components left and right, each a list as above.

Author(s)

Paul Murrell

See Also

grid.vwcurve, grid.vwline, grid.vwXspline, grid.brushXspline, grid.offsetXspline

Examples

grid.newpage()
x <- seq(.2, .8, length.out=100)
y <- .05*sin(seq(0, 2*pi, length.out=100))
w <- unit(seq(2, 10, length.out=100), "mm")
vwcg <- vwcurveGrob(x, y + 2/3, w, lineend="round",
                    gp=gpar(col="black"))
grid.draw(vwcg)
epts <- edgePoints(vwcg, 0:9/9)
grid.circle(epts$left$x, epts$left$y, r=unit(1, "mm"), 
            gp=gpar(fill=hcl(0, 80, seq(10, 100, 10))))
x <- c(.2, .4, .6, .8)
y <- c(-.05, .05, -.05, .05)
w <- unit(c(2, 4, 6, 8), "mm")
vwbg <- brushXsplineGrob(circleBrush(), x, y + 1/3, w,
                         gp=gpar(col="black"))
grid.draw(vwbg)
epts <- edgePoints(vwbg, unit(0:9, "cm"), x0=0, y0=1/3)
grid.circle(epts$x, epts$y, r=unit(1, "mm"), 
            gp=gpar(fill=hcl(0, 80, seq(10, 100, 10))))

vwline documentation built on Sept. 11, 2024, 7:56 p.m.

Related to edgePoints in vwline...