# C# CurvatureAt method outputs only 0-vectors

Hello everybody!

Whenever I calculate the curvature via CurvatureAt method in C#, the curvature vector equals 0.

This is my code:

``````            for (double incr = 0; incr < 1; incr += 0.05)
{
Point3d pt = curve.PointAtNormalizedLength(incr);
curve.ClosestPoint(pt, out double t);
Vector3d curvature = curve.CurvatureAt(t);
}
``````

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

Thomas

Hello
it is a pitty you didnâ€™t post some script because as it works very well, it is hard to tell where is your error.

curve curvature.gh (6.7 KB)

``````private void RunScript(Curve curve, ref object A, ref object B)
{
List<Point3d> pts = new List<Point3d> ();
List<Vector3d> vts = new List<Vector3d> ();
for (double incr = 0; incr < 1; incr += 0.05)
{
Point3d pt = curve.PointAtNormalizedLength(incr);
double t = 0.0;
curve.ClosestPoint(pt, out  t);
Vector3d curvature = curve.CurvatureAt(t);
}

A = pts;
B = vts;
}
``````
1 Like

I think the `for` loop could be refactored to directly loop over the curve domain, thus getting rid of some lines of code.

``````for (double t = curve.Domain.T0; t <= curve.Domain.T1; t += 0.05) {
Point3d pt = curve.PointAt(t);
Vector3d curvature = curve.CurvatureAt(t);
`T0` and `T1` should be the minimum and maximum of the curve domain.
It is. Check the documentation. `NurbsCurve` also has the `CurvatureAt` method, as it inherits from `Curve`. If youâ€™re getting a zero vector again, thereâ€™s probably a bug in your code.