File Exchange

image thumbnail

version (5.51 KB) by Benjamin Friedrich
Compute curvature, torsion and Frenet frame of space curves robustly


Updated 19 Sep 2014

View Version History

View License

This is a robust estimation of curvature, torsion, and the Frenet frame of a space curve. It works well even when data points are noisy. It uses the geometric definition of curvature as the inverse radius of an osculating circle that kisses the curve. Torsion is determined from the rotation of the osculating plane. The user can choose the level of regularization of torsion by setting a non-zero weight. A demo script presents several examples, including curves with inflection points, where the Frenet frame is ill-defined.

Cite As

Benjamin Friedrich (2021). (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Maria M.

Great code! Saved me tons of time.
Thank you so much,

Lei Xu

Dear Benjamin,
Can you please provide instructions about how to reconstruct a space curve using curvature and torsion please? Thank you very much in advance!

Best regards,

Benjamin Friedrich

Dear George,

Thanks for your questions:

Yes, the curvature of a space curve is defined only up to a global choice of sign. Still, it makes sense to define a define curvature WITH sign, since the sign may flip as you move along the curve (consider an "S", where it makes perfectly sense to assign curvature of different sign to the two bends). Also, signed curvature is needed, if you request that the Frenet frame changes smoothly along the curve. Otherwise, it would flip at inflection points.

I have not published this algorithm as a stand-alone paper, but it was used in
Jikeli, ..., Kaupp. Nature Communications 2015.


George Papas

Hi Benjamin. That's a fantastic job, thank you for this.

I would like to ask you couple of questions, which are more mathematical in nature.

1. In line 98, I am not sure why you use the rrwin_centered'*u1 and rrwin_centered'*u2 as the input for X and Y points, for fitting the circle? This possibly leads to the next question:

2. In lines 105-106, why do you calculate the atan2 of the specific vectors (i.e. rrwin_centered'*u1-xm and rrwin_centered'*u2-ym)?

3. In lines 108-109, I understand that these equations derive from the assumption that an osculating circle has a contact of order of two with the curve. Following this assumption, shouldn't these equations be as follows instead (?):


In lines 144-150, could you please explain why you used these equations to derive torsion?

Finally, signed curvature is not defined in the 3D space according to differential geometry. Can I ask what negative curvature may mean geometrically?

If you could provide any responses to understand a bit more in depth the above points, I would really appreciate it!

Let me also know how you would like to reference your work.

Best wishes,


Reza Ahmadzadeh

Nice job!

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!