def make_section(self, apex, cone_dir, alpha, cone_gen, count, plane_center, plane_dir, maxd): apex = Vector(apex) cone_dir = Vector(cone_dir) plane_dir = Vector(plane_dir) cone_dir2 = cone_dir.orthogonal() if self.cone_mode == 'ANGLE': cone_vector = rotate_vector_around_vector(cone_dir, cone_dir2, alpha) else: cone_vector = Vector(cone_gen) theta = 2 * pi / count angle = 0 plane = PlaneEquation.from_normal_and_point(plane_dir, plane_center) cone_ort_plane = PlaneEquation.from_normal_and_point(cone_dir, apex) def get_branch(v): return cone_ort_plane.side_of_point(v) > 0 if plane.side_of_point(apex) == 0 or ( plane_dir.cross(cone_dir)).length < 1e-10: def get_side(v): return True else: apex_projection = plane.projection_of_point(apex) apex_ort = apex_projection - apex cone_sagital_plane = PlaneEquation.from_point_and_two_vectors( apex, apex_ort, cone_dir) def get_side(v): return cone_sagital_plane.side_of_point(v) > 0 vertices = [] branch_mask = [] side_mask = [] breaks = [] i = 0 while angle < 2 * pi: cone_line = LineEquation.from_direction_and_point( cone_vector, apex) vertex = plane.intersect_with_line(cone_line, min_det=1e-10) if vertex is not None and (vertex - apex).length <= maxd: vertices.append(tuple(vertex)) branch = get_branch(vertex) side = get_side(vertex) branch_mask.append(branch) side_mask.append(side) i += 1 else: breaks.append(i) cone_vector = rotate_vector_around_vector(cone_vector, cone_dir, theta) angle += theta return SectionData(vertices, branch_mask, side_mask, get_branch, get_side, breaks)
def evaluate(self, u, v): point_on_curve = self.curve.evaluate(u) dv = point_on_curve - self.point result = np.array(rotate_vector_around_vector(dv, self.direction, v)) if not self.global_origin: result = result + self.point return result
def evaluate(self, t): vx = self.vectorx return self.center + rotate_vector_around_vector(vx, self.normal, t)
def evaluate(self, u, v): point_on_curve = self.curve.evaluate(u) dv = point_on_curve - self.point return np.array(rotate_vector_around_vector(dv, self.direction, v))