Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
portnov committed Sep 11, 2022
1 parent 144fe26 commit e3be1c8
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/nurbs_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,3 +898,26 @@ def test_outside_sphere_3(self):
expected_result = True
self.assertEquals(result, expected_result)

class CurveDegreeTests(SverchokTestCase):
def test_elevate_degree(self):
"""Elevate NURBS curve degree 2 -> 3"""
cpts = np.array([[-3,0.0,0], [0, 3, 0], [3,0,0]])
degree = 2
knotvector = sv_knotvector.generate(degree, len(cpts))
curve = SvNurbsCurve.build(SvNurbsCurve.NATIVE, degree, knotvector, cpts)
new_curve = curve.elevate_degree(delta = 1)
result = new_curve.get_control_points()
expected = np.array([[-3,0,0], [-1,2,0], [1,2,0], [3,0,0]])
self.assert_numpy_arrays_equal(result, expected, precision=8)

def test_reduce_degree(self):
"""Reduce NURBS curve degree 3 -> 2"""
cpts = np.array([[-3,0,0], [-1,2,0], [1,2,0], [3,0,0]])
degree = 3
knotvector = sv_knotvector.generate(degree, len(cpts))
curve = SvNurbsCurve.build(SvNurbsCurve.NATIVE, degree, knotvector, cpts)
new_curve = curve.reduce_degree(delta = 1)
result = new_curve.get_control_points()
expected = np.array([[-3,0.0,0], [0, 3, 0], [3,0,0]])
self.assert_numpy_arrays_equal(result, expected, precision=8)

0 comments on commit e3be1c8

Please sign in to comment.