def test_bulge_to_arc(): center, start_angle, end_angle, radius = bulge_to_arc(start_point=(0, 0), end_point=(1, 0), bulge=-1) assert center == (.5, 0., 0.) assert is_close(start_angle, 0) assert is_close(end_angle, math.pi) assert radius == .5
def test_arc_to_bulge(): start, end, bulge = arc_to_bulge(center=(.5, 0), start_angle=math.pi, end_angle=0, radius=.5) assert start == (0., 0., 0.) assert end == (1., 0., 0.) assert is_close(bulge, 1.)
def test_constructor_functions(): # does not check the math, because tis would just duplicate the implementation code origin = (3, 3, 3) axis = (1, 0, -1) def_point = (3, 10, 4) ucs = UCS.from_x_axis_and_point_in_xy(origin, axis=axis, point=def_point) assert ucs.is_cartesian assert is_close(ucs.from_wcs(def_point).z, 0) ucs = UCS.from_x_axis_and_point_in_xz(origin, axis=axis, point=def_point) assert ucs.is_cartesian assert is_close(ucs.from_wcs(def_point).y, 0) ucs = UCS.from_y_axis_and_point_in_xy(origin, axis=axis, point=def_point) assert ucs.is_cartesian assert is_close(ucs.from_wcs(def_point).z, 0) ucs = UCS.from_y_axis_and_point_in_yz(origin, axis=axis, point=def_point) assert ucs.is_cartesian assert is_close(ucs.from_wcs(def_point).x, 0) ucs = UCS.from_z_axis_and_point_in_xz(origin, axis=axis, point=def_point) assert ucs.is_cartesian assert is_close(ucs.from_wcs(def_point).y, 0) ucs = UCS.from_z_axis_and_point_in_yz(origin, axis=axis, point=def_point) assert ucs.is_cartesian assert is_close(ucs.from_wcs(def_point).x, 0)
def test_basis_vector_N_ip(): degree = 3 fit_points = Vector.list(POINTS2) # data points D n = len(fit_points) - 1 t_vector = list(uniform_t_vector(fit_points)) knots = list(control_frame_knots(n, degree, t_vector)) should_count = len(fit_points) - 2 # target control point count h = should_count - 1 spline = Basis(knots, order=degree + 1, count=len(fit_points)) matrix_N = [spline.basis(t) for t in t_vector] for k in range(1, n): basis_vector = bspline_basis_vector(u=t_vector[k], count=len(fit_points), degree=degree, knots=knots) for i in range(1, h): assert is_close(matrix_N[k][i], basis_vector[i])
def test_bulge_3_points(): assert is_close( bulge_3_points(start_point=(0, 0), end_point=(1, 0), point=(.5, -.5)), 1.)
def test_distance(): spiral = EulerSpiral(2.0) assert is_close(spiral.distance(10), 0.4)
def test_tangent(): spiral = EulerSpiral(2.0) assert is_close(spiral.tangent(1).angle_rad, 0.125)
def test_radius(): spiral = EulerSpiral(2.0) assert is_close(spiral.radius(1), 4.) assert is_close(spiral.radius(0), 0.)