Search code examples
bsplinenurbs

Find the radius ( or curvature ) at a point on a bspline using geomdl / nurbs


I would like to find the curvature at a given point on a 3D b-spline. I believe that I want to use the derivatives of the spline at that point to calculate the curvature at that point but I do not understand how.

I have defined a 3D bspline (taken from SolidWorks (where it came from is not relevant )) in geomdl. I can evaluate any point on the spline using Curve.evaluate_single(). This appears to work correctly. I have verified the returned points against the SolidWorks model so I assume I have implemented the bspline in nurbs correctly.

I need to find the radius at a various points along this curve. From my Google searching I think that I want to use Curve.derivatives() to calculate the instantaneous curvature at that point. But I do not understand how to get the results of Curve.derivatives() into a radius.

So below is the result of Curve.derivatives(SomePointOnPath,4):

[   [74.66019681782404, 131.77035668055586, 19.88498274391211],
    [-2719.7097781710354, -598.8099790539873, -711.5032638750225],
    [-5384.519486543373, 1273.8662545231637, 19431.220551950217],
    [93757.48746982217, -22247.397114396095, 31343.52746776864],
    [0.0, 0.0, 0.0]]

By taking points a small step either side of this point I have calculated the radius at this point to be about 409 ( Solving for radius of a circle given 3 points )

I do not understand what the results from Curve.derivatives() are telling me. (the first tuple is the coordinates of the point, beyond that I am lost)

I expect the radius at this particular point to be about 409.

My fundamental question is two parts:

What are the results telling me. What do they mean.

How do I use these result to calculate the radius at this point.


Solution

  • The radius of curvature of a curve can be computed as |C'|^3/|C' X C"| where C' and C" are the first and the 2nd derivative vectors, X is the cross product operator and |.| is the vector's magnitude. So, you will need the first and the 2nd derivatives at that point to compute the radius of curvature.

    Curve.derivatives(SomePointOnPath,4) returns the first 4 derivatives of the curve and the 0-th derivative is the position of the point on the curve. Therefore, the first derivative is [-2719.7097781710354, -598.8099790539873, -711.5032638750225] and the 2nd derivative is [-5384.519486543373, 1273.8662545231637, 19431.220551950217]. So, we can use these two vectors to do our computation and obtain a radius of curvature 408.9176414, which is close to your estimated value 409.

    On a side note, you can simply pass '3' as the 2nd argument to Curve.derivatives() as the 3rd derivatvie vector has no use in the computation of radius of curvature.