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?
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.
“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.
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.
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.