def edge_is_intersected(self, v1, v2): """ Returns True if the edge v1,v2 intersects the line in the uv domain, False otherwise. """ p = intersection_line_line_xy((self.p1, self.p2), (self.uv(v1), self.uv(v2))) if p: if is_point_on_line_xy(p, (self.uv(v1), self.uv(v2))): if is_point_on_line_xy(p, (self.p1, self.p2)): return True return False
def find_zero_crossing_data(self, v1, v2): """ Finds the position of the zero-crossing on the edge u,v. """ p = intersection_line_line_xy((self.p1, self.p2), (self.uv(v1), self.uv(v2))) d1, d2 = distance_point_point_xy(self.uv(v1), p), distance_point_point_xy( self.uv(v2), p) if d1 + d2 > 0: vec = self.mesh.edge_vector(v1, v2) vec = scale_vector(vec, d1 / (d1 + d2)) pt = add_vectors(self.mesh.vertex_coordinates(v1), vec) return pt
def get_brace_points(offset_value, offset_member, brace_CL, brace_vector, offset_dir='+'): offset_brace = offset_line(brace_CL, offset_value) if offset_dir == '+': offset_brace_signed = offset_line(brace_CL, offset_value - self.offset) elif offset_dir == '-': offset_brace_signed = offset_line(brace_CL, offset_value + self.offset) else: raise ValueError brace_member_int = intersection_line_line_xy( offset_brace, offset_member) brace_pt = translate_points_xy([brace_member_int], brace_vector)[0] pt_mirrored = mirror_points_line([brace_pt], brace_CL) line_segment = Line(brace_pt, pt_mirrored) pt_CL = intersection_line_line_xy(line_segment, brace_CL) pt_distance = distance_point_point(self.work_point, pt_CL) return line_segment, pt_distance, offset_brace, offset_brace_signed
def board_intersection(pt1, vec1, len1, pt2, vec2, len2): line1 = line_creator(pt1, vec1, len1) line2 = line_creator(pt2, vec2, len2) # to check whether the boards are parallel if vec1 != vec2: int_pt = intersection_line_line_xy(line1, line2) else: # expand here later to deal with gluing parallel boards return 0 # since intersection also hits when the lines intersect in their continuation, we have to add that one if distance_point_point(pt1, int_pt) < len1 / 2 and \ distance_point_point(pt2, int_pt) < len2 / 2: return int_pt else: return 0
def board_intersection(brd1, brd2): vec1 = Vector(brd1.length_vector[0], brd1.length_vector[1], brd1.length_vector[2]) vec2 = Vector(brd2.length_vector[0], brd2.length_vector[1], brd2.length_vector[2]) line1 = line_creator(brd1.centre_point, vec1, brd1.length) line2 = line_creator(brd2.centre_point, vec2, brd2.length) # to check whether the boards are parallel if vec1.angle(vec2) > 0.1: int_pt = intersection_line_line_xy(line1, line2) else: target_width = min(brd1.width, brd2.width) upper_boarder_1 = brd1.centre_point + brd1.width_vector*brd1.width lower_boarder_1 = brd1.centre_point # expand here later to deal with gluing parallel boards return 0 # since intersection also hits when the lines intersect in their continuation, we have to add that one if distance_point_point(brd1.centre_point, int_pt) < brd1.length / 2 and \ distance_point_point(brd2.centre_point, int_pt) < brd2.length / 2: return int_pt else: return 0
def compute_sag(pattern, opening): u, v = opening[0] if pattern.vertex_attribute(u, 'is_fixed'): a = pattern.vertex_attributes(u, 'xyz') aa = pattern.vertex_attributes(v, 'xyz') else: a = pattern.vertex_attributes(v, 'xyz') aa = pattern.vertex_attributes(u, 'xyz') u, v = opening[-1] if pattern.vertex_attribute(u, 'is_fixed'): b = pattern.vertex_attributes(u, 'xyz') bb = pattern.vertex_attributes(v, 'xyz') else: b = pattern.vertex_attributes(v, 'xyz') bb = pattern.vertex_attributes(u, 'xyz') span = distance_point_point_xy(a, b) apex = intersection_line_line_xy((a, aa), (b, bb)) if apex is None: rise = 0.0 else: midspan = midpoint_point_point_xy(a, b) rise = 0.5 * distance_point_point_xy(midspan, apex) sag = rise / span return sag