Curve Parameter t in Curve.CurvatureAt Method

Hello there!

I want to evaluate the curvature of a curve at certain lengths of the curve. There is the Curve.CurvatureAt Method (Curve.CurvatureAt Method), which can be evaluated at the parameter t. However, it is not stated what this parameter is. Does someone know?

Thanks for the help!
Thomas

Curve.PointAtLength then Curve.ClosestPoint could be a way

1 Like

A curve has a domain usually from 0.0 to it’s length, or if it’s normalized from 0.0 to 1.0. t is a parameter on the curve within that domain.
In case of the normalized curve, the parameter 0.5 would be at the middle of the curve.
The t parameter can be used to find points that lie on the curve (cf. Curve.PointAt Method).
If you already have a point that lies on the curve and you want to find its curve parameter t, you can simply look for the corresponding closest point (cf. Curve.ClosestPoint Method (Point3d, Double)), which will give you t.

Great, thanks for the quick help!!

Is there a quick way to find out, whether the curve is normalized or not?

@diff-arch not sure what you mean by normalized? Reparametrized? If it’s the latter then this will not guarantee middle of curve at 0.5

doing it this way is fool-proof:

2 Likes

You can for instance look at the curve domain (cf. https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_Geometry_Curve_Domain.htm). If it starts at 0.0 and ends at 1.0, the curve can be considered normalized.
You can also treat a non-normalized curve as normalized by using the https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Curve_PointAtNormalizedLength.htm . It’s easier to think about a curve domain from 0.0 to 1.0 than for instance a domain from -2.75 to 8.126.

1 Like

Ah I see… mine was just a convoluted way to get the same :slight_smile:

“Reparameterized” is Grasshopper lingo, in trigonometry and programming, this is usually referred to as “normalized”, much like a normalized vector has magnitude 1.0, a normalized line or curve has a domain from 0.0 to 1.0.

hence my comment:

If you reparametrize a curve in gh, getting the point at parameter 0.5 will not guarantee the curve midpoint, whereas the method Curve.PointAtNormalizedLength() will.

Yes, I was just trying to explain curves domains in an easy fashion to OP.

Sorry to bring this back up again. Whenever I calculate the curvature as you have explained it, my curvature vector equals 0.

This is my code:

            for (double incr = 0; incr < 1; incr += 0.05)
            {
                Point3d ptSegI = segI.PointAtLength(incr * segI.GetLength());
                segI.ClosestPoint(ptSegI, out double t);
                Vector3d curvSegI = segI.CurvatureAt(t);
            }

If I do the same calculation with the DerivativeAt method, it works out fine. Why is the CurvatureAt method not working here?

Thanks for your help.
Thomas

I’m not exactly sure, since I’m not really familiar with C#, but could it be that you need to declare the variable t, before passing it by reference to ClosestPoint?

double t;  // probably to be declared outside of the loop?
segI.ClosestPoint(ptSegI, t);  // it could be that it's not even necessary to provide t here?

You can also get rid of the multiplication that you pass to PointAtLength, by simply using PointAtNormalizedLength with incr instead.

Point3d ptSegI = segI.PointAtNormalizedLength(incr);
1 Like

Thanks for your answer!

Unfortunately, declaring t outside was not the solution. I might start a new topic with my question.

Thanks for the help!