I have created a NURBS curve using a set of 7 3d points as follows:
foo = { Vec3d(-2.31255173888013310,13.71874169674855715,9.96767262774798724),
Vec3d(-1.60851217809527469,13.64378920058454625,10.56913925936209075),
Vec3d(-0.84704006712084179,13.51984274121200258,11.04290482577390264),
Vec3d(0.01010111903048229,13.36582170257568869,11.21720180288246738),
Vec3d(0.86512194155175459,13.52090324692926515,11.03197932891344379),
Vec3d(1.59410746426513139,13.59934835945560216,10.51352413455335366),
Vec3d(2.28612161492324351,13.72519642394544981,9.94316689926720443) };
ON_NurbsCurve my_curve( 3, false, 3+1, foo.size());
for (std::size_t i=0; i<foo.size(); ++i)
{
my_curve.SetCV(i, ON_3dPoint(foo[i].x, foo[i].y, foo[i].z));
}
my_curve.MakeClampedUniformKnotVector();
The curve is created properly as shown in the screenshot below:
I am trying to get the tangents of the curve at specific t’s, where t
is the parameter of the individual foo
point, ex. {t=0.0, foo[0]} , {t=0.14, foo[1]} , {t=0.28, foo[2]} ...
, using the following:
ON_3dVector tangent = my_curve.TangentAt( t );
Unfortunately, the tangents of the curve are not correct (see screenshot below):
I have also tried the following member functions:
CurvatureAt
EvCurvature
EvSignedCurvature
EvTangent
SignedCurvatureAt
But they all return similar or incorrect results. Can you please help me identify my mistake?