SINTEF / Splipy

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

Tolerance problems with `make_splines_identical( )` #84

Closed VikingScientist closed 3 years ago

VikingScientist commented 5 years ago
from splipy import BSplineBasis, Curve                                         
from splipy.state import state                                                 
import numpy as np                                                             

b1 = BSplineBasis(order=4, knots=[0,0,0,0, 0.33333333333333326, 0.33333333333333326, 0.33333333333333326, 1,1,1,1])
b2 = BSplineBasis(order=4, knots=[0,0,0,0, 0.3333333333333333 , 0.3333333333333333 , 0.3333333333333333 , 1,1,1,1])
crv1 = Curve(b1, np.random.random((7,2)))                                      
crv2 = Curve(b2, np.random.random((7,2)))                                      
print('=============  BEFORE  ==================')                             
print(crv1.knots(0,True))                                                                    
print(crv2.knots(0,True))                                                                    
Curve.make_splines_identical(crv1,crv2)                                        
print('=============  AFTER  ==================')                              
print(crv1.knots(0,True))                                                                    
print(crv2.knots(0,True))                                                                    

Gives output:

=============  BEFORE  ==================
[0.         0.         0.         0.         0.33333333 0.33333333
 0.33333333 1.         1.         1.         1.        ]
[0.         0.         0.         0.         0.33333333 0.33333333
 0.33333333 1.         1.         1.         1.        ]
=============  AFTER  ==================
[0.         0.         0.         0.         0.33333333 0.33333333
 0.33333333 0.33333333 0.33333333 1.         1.         1.
 1.        ]
[0.         0.         0.         0.         0.33333333 0.33333333
 0.33333333 1.         1.         1.         1.        ]

Notice that the first curve have the knot 1/3 duplicated 5 times.

VikingScientist commented 5 years ago

Pretty sure that the error lies in BSplineBasis.continuity()