# curvature_spline: Calculate total curvature from smoothing or interpolating... In mannfred/curvr: Calculate Total Curvature From Landmarked Specimens

 curvature_spline R Documentation

## Calculate total curvature from smoothing or interpolating splines.

### Description

Calculate total curvature from smoothing or interpolating splines.

### Usage

``````curvature_spline(landmark_matrix, x_range, type = "smooth")
``````

### Arguments

 `landmark_matrix` is a `matrix` object with `[,1]` containing the x landmark coordinates and `[,2]` containing the y landmark coordinates. `x_range` the lower and upper x-value bounds to calculate curvature. Concatenate the lower and upper bounds using `c()`, E.g. for lower = 1 and upper = 10, type `c(1,10)`. `type` either 'ip' for an interpolating spline or 'smooth' for a smoothing spline. Uses `stats::spline()` or `stats::smooth.spline()`, respectively, for curve fitting and estimating the derivatives. Default is `type = 'smooth'`. See: ?spline and ?smooth.spline for details.

### Value

a 'list' with two named elements. '\$Ktot' is the total curvature in radians. '\$Ki' is a numeric vector of local curvature values.

### Examples

``````
# a landmark matrix describing a segment of the unit circle#'
x <- seq(0, 1, by = 0.01)
y <- sqrt(1-x^2)
mdat <- matrix(c(x, y), nrow = 101, ncol = 2)

# total curvature between x=0 and x=sqrt(2)/2 should be approximately pi/4
abs(curvature_spline(mdat, c(0, sqrt(2)/2), type='smooth')\$Ktot)

``````

mannfred/curvr documentation built on Aug. 30, 2023, 12:07 p.m.