def eval_internal(self): print('>' * 50) print(self) segment = Segment2D(self._first_point.vector, self._second_point.vector) circle = Circle2D(self._center.vector, self._radius.value) points = circle.intersect_segment(segment) # Fixme: multi-points ??? if not points: self._logger.warning('line-circle intersection is null') self._vector = None elif len(points) == 1: self._vector = points[0] else: self._logger.warning( 'More than one points for line-circle intersection') # point must lie in the segment point0 = points[0] segment.contain_point(points[0]) segment.contain_point(points[1]) print('>' * 50) if segment.contain_point(point0): self._vector = point0 else: # Fixme: more than two points ??? self._vector = points[1] self._post_eval_internal()
def geometry(self): items = [] for vertex1, vertex2 in self.iter_on_segment(): segment = Segment2D(vertex1.point, vertex2.point) if vertex1.bulge: segment_center = segment.center direction = vertex1.segment_vector.normalise() normal = direction.normal # offset = vertex1.bulge_radius - vertex1.sagitta offset = vertex1.sagitta_dual center = segment_center + normal * sign(vertex1.bulge) * offset arc = Circle2D(center, vertex1.bulge_radius) start_angle, stop_angle = [ arc.angle_for_point(vertex.point) for vertex in (vertex1, vertex2) ] if start_angle < 0: start_angle += 360 if stop_angle < 0: stop_angle += 360 if vertex1.bulge < 0: start_angle, stop_angle = stop_angle, start_angle # print('bulb', vertex1, vertex2, vertex1.bulge, start_angle, stop_angle) arc.domain = AngularDomain(start_angle, stop_angle) # arc = Circle2D(center, vertex1.bulge_radius, domain=AngularDomain(start_angle, stop_angle)) items.append(arc) else: items.append(segment) return items
def _on_circle(self, item, is_arc): item_dxf = item.dxf center = self._to_vector(item_dxf.center) if is_arc: domain = AngularDomain(item_dxf.start_angle, item_dxf.end_angle) else: domain = None circle = Circle2D(center, item_dxf.radius, domain=domain) self._add(circle)
def _make_figure1(self): width = 30 space = 2 seam_length = width / 4 long_arm_length = width / 2 short_arm_length = long_arm_length * .6 height = 4 radius = 2 vertical_seam_position = short_arm_length * 2 / 3 vertical_seam_length = height * 1.5 right_side_length = width / 4 y_right_side = height * 1.5 right_side_circle_radius = 1 path1 = Path2D((short_arm_length + space / 2, -height / 2)) path1.west_to(short_arm_length) path1.north_to(height, radius=radius) path1.east_to(long_arm_length, radius=radius) path2 = path1.x_mirror(clone=True) path3 = Path2D((-seam_length / 2, 0)) path3.east_to(seam_length) path4 = Path2D((vertical_seam_position, -vertical_seam_length / 2)) path4.north_to(vertical_seam_length) path5 = path4.x_mirror(clone=True) path6 = Path2D((-right_side_length / 2, y_right_side)) path6.east_to(right_side_length) circle = Circle2D((0, y_right_side), right_side_circle_radius) return [path1, path2, path3, path4, path5, path6, circle]
def get_geometry(self): position = self.casted_position # Fixme: radius domain = AngularDomain(self._start_angle, self._stop_angle) return Circle2D(position, self._radius, domain=domain)