def process(self): if not any(socket.is_linked for socket in self.outputs): return point1_s = self.inputs['Point1'].sv_get() point2_s = self.inputs['Point2'].sv_get() point3_s = self.inputs['Point3'].sv_get() point1_s = ensure_nesting_level(point1_s, 3) point2_s = ensure_nesting_level(point2_s, 3) point3_s = ensure_nesting_level(point3_s, 3) arcs_out = [] circles_out = [] centers_out = [] radius_out = [] angle_out = [] for point1s, point2s, point3s in zip_long_repeat( point1_s, point2_s, point3_s): arcs_new = [] circles_new = [] centers_new = [] radius_new = [] angle_new = [] for point1, point2, point3 in zip_long_repeat( point1s, point2s, point3s): circle_data = circle_by_three_points(point1, point2, point3) if circle_data is None: raise Exception( "Can't build a circle by these points: {}, {}, {}". format(point1, point2, point3)) matrix = circle_data.get_matrix() circle = SvCircle(matrix, circle_data.radius) arc = SvCircle(matrix, circle_data.radius) arc.u_bounds = (0.0, circle_data.arc_angle) arcs_new.append(arc) circles_new.append(circle) centers_new.append(matrix) radius_new.append(circle_data.radius) angle_new.append(circle_data.arc_angle) if self.join: arcs_out.extend(arcs_new) circles_out.extend(circles_new) centers_out.extend(centers_new) radius_out.extend(radius_new) angle_out.extend(angle_new) else: arcs_out.append(arcs_new) circles_out.append(circles_new) centers_out.append(centers_new) radius_out.append(radius_new) angle_out.append(angle_new) self.outputs['Arc'].sv_set(arcs_out) self.outputs['Circle'].sv_set(circles_out) self.outputs['Center'].sv_set(centers_out) self.outputs['Radius'].sv_set(radius_out) self.outputs['Angle'].sv_set(angle_out)
def test_arc_2(self): pt1 = (-5, 0, 0) pt2 = (-4, 3, 0) pt3 = (-3, 4, 0) eq = circle_by_three_points(pt1, pt2, pt3) matrix = eq.get_matrix() arc = SvCircle(matrix, eq.radius) arc.u_bounds = (0.0, eq.arc_angle) nurbs = arc.to_nurbs() u_min, u_max = nurbs.get_u_bounds() self.assertEquals(u_min, 0, "U_min") self.assertEquals(u_max, eq.arc_angle, "U_max") startpoint = nurbs.evaluate(u_min) self.assert_sverchok_data_equal(startpoint.tolist(), pt1, precision=8) endpoint = nurbs.evaluate(u_max) self.assert_sverchok_data_equal(endpoint.tolist(), pt3, precision=8)
def test_arc_3(self): pt1 = np.array((-4, 2, 0)) pt2 = np.array((0, 2.5, 0)) pt3 = np.array((4, 2, 0)) eq = circle_by_three_points(pt1, pt2, pt3) #matrix = eq.get_matrix() arc = SvCircle(center=np.array(eq.center), vectorx=np.array(pt1 - eq.center), normal=eq.normal) arc.u_bounds = (0.0, eq.arc_angle) nurbs = arc.to_nurbs() u_min, u_max = nurbs.get_u_bounds() self.assertEquals(u_min, 0, "U_min") self.assertEquals(u_max, eq.arc_angle, "U_max") startpoint = nurbs.evaluate(u_min) self.assert_sverchok_data_equal(startpoint.tolist(), pt1, precision=6) endpoint = nurbs.evaluate(u_max) self.assert_sverchok_data_equal(endpoint.tolist(), pt3, precision=6)