SINTEF / Splipy

Spline modelling made easy.
GNU General Public License v3.0
100 stars 18 forks source link

`Surface.const_par_curve` gives unexpected results when working around an inner knot #168

Open UnaiSan opened 5 months ago

UnaiSan commented 5 months ago

I have seen the following unexpected (for me) behaviour in Surface.const_par_curve.

from splipy import Curve, BSplineBasis
from splipy.surface_factory import loft

bu = splipy.BSplineBasis(4)
crv1 = splipy.Curve(bu, [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]], raw=True)
crv2 = splipy.Curve(bu, [[0, 0, 3.5], [0.2, 0, 3.5], [0.2, 0.8, 3.5], [0, 0.7, 3.5]], raw=True)
crv3 = splipy.Curve(bu, [[0.2, -0.4, 5], [0.2, 1, 5], [0.6, 0.8, 5], [-0.5, 1.7, 5]], raw=True)
crv4 = splipy.Curve(bu, [[-0.2, 0.1, 7], [0.28, 1.5, 7], [0.1, -0.8, 7], [0.5, 1.0, 7]], raw=True)
srf = surface_factory.loft(crv1, crv2, crv3, crv4)
srf.bases[1].normalize()
srf.insert_knot(0.85, direction=1)

# srf.bases[1] is [0, 0, 0, 0, 0.85, 1, 1, 1, 1]

The calls to evaluate and const_par_curve give different results when we work around the inner knot 0.85

srf(0, 0.85 + 1e-10)
# array([ 0.14586581, -0.37665208,  5.93847258])
srf.const_par_curve(0.85 + 1e-10, direction=1)(0)
# array([ 0.08664116, -0.30658523,  6.28807807])

Those results should be the same, or at least very similar. The call to evaluate includes a call to snap the parameter, but in the const_par_curve this effect is not achieved.