File Exchange

## Curvature of a 1D curve in a 2D or 3D space

version 1.2.5 (82.2 KB) by
Calculates the local radius of curvature as well as the cumulative arc length and the curvature vector along a 1D curve in 2D or 3D space

Updated 19 Oct 2020

Function circumcenter finds the radius R and the center of the circumscribed circle of a triangle in 3D space.

Function curvature calls circumcenter for every triplet P_i-1, P_i, P_i+1 of neighboring points along the curve. The curvature is defined as κ_i = 1/R_i. The curvature vector is k_i=ε_i/R, where ε_i is the unit vector in the direction from P_i to the center of the circle.

Note that this local calculation is sensitive to noise in the data.

The syntax is:

[L,R,K] = curvature(X)
X: array of column vectors for the curve coordinates. X may have two or three columns.
L: Arc length
K: Curvature vector

### Cite As

Are Mjaavatten (2021). Curvature of a 1D curve in a 2D or 3D space (https://www.mathworks.com/matlabcentral/fileexchange/69452-curvature-of-a-1d-curve-in-a-2d-or-3d-space), MATLAB Central File Exchange. Retrieved .

Are Mjaavatten

Hi WJ: Sorry I did not see your comment earlier. The curvature vector K gives the size and direction of the curvature. It always points towards the concave side of the curve.

WJ

Hi Are, it seems that this analysis is unable to distinguish between curves that bend in opposite directions. Is that true? I'm only getting positive curvature values with dataset that consists of opposite bends. Please advise. Thanks.

J AI

Are Mjaavatten

Giuseppe Pontrelli: Handles1D curves only. The original title (Curvature of a 2D or 3D curve) was somewhat misleading.

Nino Vroom

Yuanshu Zhang

Giuseppe Pontrelli

Does the algorithm work also for concave 2D curves? how does the algorithm distinguish a convex and a concave point?

Wentao Zhao

Ines Chavarria

hossein soleimani

Yongkai liu

STEEVE MBAKOP

Very great

Mandeep Dhanda

Vasileios Basios

Are Mjaavatten

Matthew Wong: Three points are required to calculate the curvature and direction. Thus the arrays R and Kappa are not defined at the end points. I have chosen to use the value NaN at those points. I could have made the arrays smaller or used zeros, but NaN makes it easier to make nice plots.

Matthew Wong

I used parts of this function to solve the problem that initially inspired this function's creation. What does it mean if an 'e' value returns NaN? I believe that the sign of 'e' determines curve direction (either 1 or -1) but I'm not sure what the NaN means.

##### MATLAB Release Compatibility
Created with R2014b
Compatible with any release
##### Platform Compatibility
Windows macOS Linux