fm_bary {fmesher}R Documentation

Compute barycentric coordinates

Description

Identify knot intervals or triangles and compute barycentric coordinates

Usage

fm_bary(...)

## S3 method for class 'fm_bary'
fm_bary(bary, ..., extra_class = NULL)

## S3 method for class 'list'
fm_bary(bary, ..., extra_class = NULL)

## S3 method for class 'tbl_df'
fm_bary(bary, ..., extra_class = NULL)

## S3 method for class 'fm_mesh_1d'
fm_bary(mesh, loc, method = c("linear", "nearest"), restricted = FALSE, ...)

## S3 method for class 'fm_mesh_2d'
fm_bary(mesh, loc, crs = NULL, ..., max_batch_size = NULL)

## S3 method for class 'fm_mesh_3d'
fm_bary(mesh, loc, ..., max_batch_size = NULL)

## S3 method for class 'fm_lattice_2d'
fm_bary(mesh, loc, crs = NULL, ...)

## S3 method for class 'fm_lattice_Nd'
fm_bary(mesh, loc, ...)

Arguments

...

Arguments forwarded to sub-methods.

bary

An fm_bary object, or an object that can be converted to fm_bary.

extra_class

character; If non-NULL and not already in the class vector of bary, add it to the front of the class vector.

mesh

fm_mesh_1d or fm_mesh_2d object

loc

Points for which to identify the containing interval/triangle, and corresponding barycentric coordinates. May be a vector (for 1d) or a matrix of raw coordinates, sf, or sp point information (for 2d).

method

character; method for defining the barycentric coordinates, "linear" (default) or "nearest"

restricted

logical, used for method="linear". If FALSE (default), points outside the mesh interval will be given barycentric weights less than 0 and greater than 1, according to linear extrapolation. If TRUE, the barycentric weights are clamped to the (0, 1) interval.

crs

Optional crs information for loc

max_batch_size

integer; maximum number of points to process in a single batch. This speeds up calculations by avoiding repeated large internal memory allocations and data copies. The default, NULL, uses max_batch_size = 2e5L, chosen based on empirical time measurements to give an approximately optimal runtime.

Value

A fm_bary object, a tibble with columns index; either

and where, a matrix of barycentric coordinates.

Methods (by class)

See Also

fm_bary_simplex(), fm_bary_loc()

Examples

bary <- fm_bary(fm_mesh_1d(1:4), seq(0, 5, by = 0.5))
bary
str(fm_bary(fmexample$mesh, fmexample$loc_sf))
m <- fm_mesh_3d(
  rbind(
    c(1, 0, 0),
    c(0, 1, 0),
    c(0, 0, 1),
    c(0, 0, 0)
  ),
  matrix(c(1, 2, 3, 4), 1, 4)
)
b <- fm_bary(m, matrix(c(1, 1, 1) / 4, 1, 3))
str(fm_bary(fmexample$mesh, fmexample$loc_sf))

[Package fmesher version 0.5.0 Index]