def bspline_3d(): surface = an.NurbsSurfaceGeometry3D( degree_u=2, degree_v=1, nb_poles_u=4, nb_poles_v=3, is_rational=False, ) surface.knots_u = [0, 0, 7.5, 15, 15] surface.knots_v = [0, 10, 20] surface.poles = [ [-10.0, -5.0, -1.0], [-12.0, 3.0, 3.0], [-9.0, 11.0, -0.0701928417], [-5.0, -3.0, 1.0], [-6.0, 4.0, -2.0], [-5.0, 7.0, 0.9298071583], [0.0, -4.0, -1.0], [1.0, 6.0, 5.0], [0.0, 13.0, -0.2350184214], [4.0, -2.0, 0.0], [5.0, 4.0, -1.0], [5.0, 11.0, 0.7649815786], ] return surface
def test_curve_on_surface_3d(self): curve = an.NurbsCurveGeometry2D( degree=2, nb_poles=3, is_rational=False, ) curve.knots = [7, 7, 9, 9] curve.poles = [ [3, 2], [1, 4], [2, 5], ] surface = an.NurbsSurfaceGeometry3D( degree_u=2, degree_v=2, nb_poles_u=3, nb_poles_v=3, is_rational=False, ) surface.knots_u = [1, 1, 3, 3] surface.knots_v = [2, 2, 6, 6] surface.poles = [ [0, 0, 3], [0, 5, 0], [0, 10, 2], [5, 0, 5], [5, 5, 0], [5, 10, 3], [10, 0, 1], [10, 5, -1], [10, 10, 0], ] curve_on_surface = an.CurveOnSurface3D(curve, surface, curve.domain) assert_almost_equal(curve_on_surface.point_at(t=8), [3.75, 4.375, 1.5063476563]) assert_almost_equal( curve_on_surface.derivatives_at(t=8, order=2), [[3.75, 4.375, 1.5063476563], [-2.5, 3.75, -0.658203125], [7.5, -1.25, 1.1621094]], ) spans = curve_on_surface.spans self.assertEqual(len(spans), 1) self.assertEqual(spans[0].t0, 7) self.assertEqual(spans[0].t1, 9)
def test_bspline_3d(): surface_geometry = an.NurbsSurfaceGeometry3D( degree_u=2, degree_v=1, nb_poles_u=4, nb_poles_v=3, is_rational=False, ) surface_geometry.knots_u = [0, 0, 7.5, 15, 15] surface_geometry.knots_v = [0, 10, 20] surface_geometry.poles = [ [-10.0, - 5.0, -1.0 ], [-12.0, 3.0, 3.0 ], [- 9.0, 11.0, -0.0701928417], [- 5.0, - 3.0, 1.0 ], [- 6.0, 4.0, -2.0 ], [- 5.0, 7.0, 0.9298071583], [ 0.0, - 4.0, -1.0 ], [ 1.0, 6.0, 5.0 ], [ 0.0, 13.0, -0.2350184214], [ 4.0, - 2.0, 0.0 ], [ 5.0, 4.0, -1.0 ], [ 5.0, 11.0, 0.7649815786], ] model = an.Model() surface_geometry_ptr = model.add(surface_geometry) surface = an.Surface3D(surface_geometry_ptr) # point_at assert_array_almost_equal( surface.point_at(u=12, v=5), [1.46, 0.96, 0.9], ) # derivarives_at assert_array_almost_equal( surface.derivatives_at(u=12, v=5, order=2), [[1.46, 0.96, 0.9], [0.96, 0.0266666667, -0.2666666667], [0.084, 0.832, 0.276], [0.0355555556, -0.0088888889, -0.1333333333], [0.0106666667, -0.048, -0.064], [0, 0, 0]], )
def test_bspline_list_constructor(): an.NurbsSurfaceGeometry3D( degree_u=2, degree_v=1, knots_u=[0.0, 0.0, 7.5, 15.0, 15.0], knots_v=[0.0, 10.0, 20.0], poles=[ [-10.0, -5.0, -1.0], [-12.0, 3.0, 3.0], [-9.0, 11.0, -0.0701928417], [-5.0, -3.0, 1.0], [-6.0, 4.0, -2.0], [-5.0, 7.0, 0.9298071583], [0.0, -4.0, -1.0], [1.0, 6.0, 5.0], [0.0, 13.0, -0.2350184214], [4.0, -2.0, 0.0], [5.0, 4.0, -1.0], [5.0, 11.0, 0.7649815786], ], )