create_path: Create coordinates following defined trajectory

Description Usage Arguments Value Examples

View source: R/create_path.R

Description

Manually create data points corresponding to piecewise polynomial.

Use create_path() to exert full control over trajectory shape. Starting with scalar values defined by nodes, create_path() integrates twice to create continuously differentiable function.

create_path() is the underlying function to meandr().

If you are trying to generate random curve, it is strongly recommended to use meandr().

Usage

1
2
3
4
5
6
create_path(
  n_points = 100,
  nodes = c(1, -1, -1, 2, 0),
  node_int = NULL,
  scale = 1
)

Arguments

n_points

An integer. Controls output "resolution". (Underlying calculus is unaffected).

nodes

A numeric vector corresponding to 2nd derivative values. This determines the overall shape of the function.

node_int

A numeric vector assigning x-values for nodes. Automatically placed at equal intervals if NULL.

scale

A number. Adjusts all y-values so that max(y) = scale.

Value

A tibble containing coordinates of resulting function.

Examples

1
2
3
4
5
# quadratic increase followed by linear slope
create_path(nodes = c(1, 0))

# resembles sinusoid
create_path(nodes = c(1, -1, 1, -1, 1), node_int = c(0, 0.125, 0.375, 0.625, 0.875))

sccmckenzie/meandr documentation built on May 5, 2021, 4:23 a.m.