Learn R Programming

boostmath (version 1.4.0)

catmull_rom: Catmull-Rom Interpolation

Description

Constructs a Catmull-Rom spline interpolator given control points.

Usage

catmull_rom(control_points, closed = FALSE, alpha = 0.5)

Value

An object of class catmull_rom with methods:

  • interpolate(xi): Evaluate the interpolator at point xi.

  • prime(xi): Evaluate the derivative of the interpolator at point xi.

  • max_parameter(): Get the maximum parameter value of the spline.

  • parameter_at_point(i): Get the parameter value at index i.

Arguments

control_points

List of control points, where each element is a numeric vector of length 3.

closed

Logical indicating whether the spline is closed (i.e., the first and last control points are connected), defaults to false

alpha

Numeric scalar for the tension parameter, defaults to 0.5

Examples

Run this code
control_points <- list(c(0, 0, 0), c(1, 1, 0), c(2, 0, 0), c(3, 1, 0))
interpolator <- catmull_rom(control_points)
xi <- 1.5
interpolator$interpolate(xi)
interpolator$prime(xi)
interpolator$max_parameter()
interpolator$parameter_at_point(2)

Run the code above in your browser using DataLab