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().

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

# quadratic increase followed by linear slope create_path(nodes = c(1, 0))
#> Creating even-spaced node intervals at 0%, 50%
#> # A tibble: 100 x 2 #> t f #> <dbl> <dbl> #> 1 0.01 0.000133 #> 2 0.02 0.000533 #> 3 0.03 0.00120 #> 4 0.04 0.00213 #> 5 0.05 0.00333 #> 6 0.06 0.0048 #> 7 0.0700 0.00653 #> 8 0.08 0.00853 #> 9 0.09 0.0108 #> 10 0.10 0.0133 #> # ... with 90 more rows
# resembles sinusoid create_path(nodes = c(1, -1, 1, -1, 1), node_int = c(0, 0.125, 0.375, 0.625, 0.875))
#> # A tibble: 100 x 2 #> t f #> <dbl> <dbl> #> 1 0.01 0.0032 #> 2 0.02 0.0128 #> 3 0.03 0.0288 #> 4 0.04 0.0512 #> 5 0.05 0.08 #> 6 0.06 0.115 #> 7 0.0700 0.157 #> 8 0.08 0.205 #> 9 0.09 0.259 #> 10 0.10 0.320 #> # ... with 90 more rows