File Exchange

Curvature of a 2D or 3D curve

version 1.2.3 (82.4 KB) by Are Mjaavatten

Are Mjaavatten (view profile)

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 26 Nov 2018

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 (2019). Curvature of a 2D or 3D curve (https://www.mathworks.com/matlabcentral/fileexchange/69452-curvature-of-a-2d-or-3d-curve), MATLAB Central File Exchange. Retrieved .

Ines Chavarria

Ines Chavarria (view profile)

hossein soleimani

Yongkai liu

STEEVE MBAKOP

Very great

Mandeep Dhanda

Vasileios Basios

Are Mjaavatten

Are Mjaavatten (view profile)

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

Matthew Wong (view profile)

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.