Incorrect tangents of NURBS curve

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?

1 Like

Not an OpenNURBS user here …

… But I think that the parameter values might be the problem.
Where did you pick those values from ? :slight_smile:

I think you can check where a parameter values lies on the curve using

PointAt

You might check the curve domain by

GetDomain

Also find the parameter value of a point on the curve near a 3D point by
GetClosestPoint

HTH

2 Likes

Indeed! The domain of the curve was 4. I am used to normalized parametric curves and didn’t consider to check. Thanks.

2 Likes

You better to upload the full script .
From the second part of your message it looks like you’re not passing multiple t as a list but only one t so it keeps the t=0

Without the script it’s hard to help more

1 Like

I think you can change the domain as you like by
SetDomain

1 Like

Hi @Constantinos_Glynos,

Poorly parameterized objects may not intersect and trim properly when combined with other objects. “Poorly parameterized” means the curve’s domain or the surface’s u or v spaces are tiny or huge compared to the size of the object.

When curves and surfaces are paramterized with a [0,1] domain, both the accuracy and the precision of geometric calculations like intersections and closest points are reduced, sometimes dramatically. Ideally the domain of a curve is close to it’s length and the domains of a surface is close to is average breadth in the appropriate direction.

We try to have parameterization match the length of a curve or some measure of the width of the surface. Derivative information is better if we do it this way.

If you’re using C++ and need a normalized parameter from an interval parameter, use ON_Interval::NormalizedParameterAt.

Likewise, if you have a normalized parameter and need an interval parameter, use ON_Interval::ParameterAt.

– Dale

2 Likes