def test_nurbs_init_with_knots_raises(nurbs_3d): with pytest.raises(RuntimeError): an.NurbsCurveGeometry3D( degree=4, knots=np.empty(5), poles=np.empty((5, 3)), )
def nurbs_3d(): geometry = an.NurbsCurveGeometry3D( degree=4, nb_poles=8, is_rational=True, ) geometry.knots = [ 0, 0, 0, 0, 32.9731425998736, 65.9462851997473, 98.9194277996209, 131.892570399495, 131.892570399495, 131.892570399495, 131.892570399495 ] geometry.poles = [ [0, -25, -5], [-15, -15, 0], [5, -5, -3], [15, -15, 3], [25, 0, 6], [15, 15, 6], [-5, -5, -3], [-25, 15, 4], ] geometry.weights = [1, 3, 1, 2.5, 1, 0.5, 1, 2] return geometry
def test_bspline_3d(): curve_geometry = an.NurbsCurveGeometry3D( degree=4, nb_poles=8, is_rational=False, ) curve_geometry.knots = [0, 0, 0, 0, 32.9731425998736, 65.9462851997473, 98.9194277996209, 131.892570399495, 131.892570399495, 131.892570399495, 131.892570399495] curve_geometry.poles = [ [ 0, -25, - 5], [-15, -15, 0], [ 5, - 5, - 3], [ 15, -15, 3], [ 25, 0, 6], [ 15, 15, 6], [- 5, - 5, - 3], [-25, 15, 4], ] model = an.Model() curve_geometry_ptr = model.add(curve_geometry) curve = an.Curve3D(curve_geometry_ptr, curve_geometry.domain) # point_at assert_array_almost_equal( curve.point_at(t=65.9462851997), [18.8888888889, -6.1111111111, 4.1666666667], )
def test_nurbs_by_lists(): an.NurbsCurveGeometry3D( degree=4, knots=[ 0, 0, 0, 0, 32.9731425998736, 65.9462851997473, 98.9194277996209, 131.892570399495, 131.892570399495, 131.892570399495, 131.892570399495 ], poles=[[0, -25, -5], [-15, -15, 0], [5, -5, -3], [15, -15, 3], [25, 0, 6], [15, 15, 6], [-5, -5, -3], [-25, 15, 4]], weights=[1, 3, 1, 2.5, 1, 0.5, 1, 2], )
def curve(): curve_geometry = an.NurbsCurveGeometry3D(degree=4, nb_poles=8) curve_geometry.knots = [3, 3, 3, 3, 6.5, 10, 13.5, 17, 17, 17, 17] curve_geometry.poles = [ [ 0, -25, - 5], [-15, -15, 0], [ 5, - 5, - 3], [ 15, -15, 3], [ 25, 0, 6], [ 15, 15, 6], [- 5, - 5, - 3], [-25, 15, 4], ] return curve_geometry
def empty_bspline(): return an.NurbsCurveGeometry3D( degree=2, nb_poles=4, is_rational=False, )