def draw(coxeter_diagram, trunc_type, description="polychora", extra_relations=(), **kwargs): coxeter_matrix = helpers.make_symmetry_matrix( [x.numerator for x in coxeter_diagram]) mirrors = helpers.get_mirrors(coxeter_diagram) P = Polychora(coxeter_matrix, mirrors, trunc_type, extra_relations) P.build_geometry() write_to_pov(P, **kwargs) print("rendering {} with {} vertices, {} edges, {} faces".format( description, P.num_vertices, P.num_edges, P.num_faces)) process = subprocess.Popen(POV_COMMAND.format(description), shell=True, stderr=subprocess.PIPE, stdin=subprocess.PIPE, stdout=subprocess.PIPE) _, err = process.communicate() if process.returncode: print(type(err), err) raise IOError("POVRay error: " + err.decode("ascii"))
def anim(coxeter_diagram, trunc_type, description="polyhedra", snub=False, extra_relations=()): """Call POV-Ray to render the frames and FFmpeg to generate the movie. """ coxeter_matrix = helpers.fill_matrix( [x.numerator for x in coxeter_diagram]) mirrors = helpers.get_mirrors(coxeter_diagram) if snub: P = Snub(coxeter_matrix, mirrors, trunc_type) else: P = Polyhedra(coxeter_matrix, mirrors, trunc_type, extra_relations) P.build_geometry() write_to_pov(P) process = subprocess.Popen(POV_COMMAND.format(description), shell=True, stderr=subprocess.PIPE, stdin=subprocess.PIPE, stdout=subprocess.PIPE) _, err = process.communicate() if process.returncode: print(type(err), err) raise IOError("POVRay error: " + err.decode("ascii")) subprocess.call(FFMPEG_COMMAND.format(description, description), shell=True)
def main(): coxeter_diagram = (5, 2, 2, 3, 2, 3) coxeter_matrix = helpers.fill_matrix(coxeter_diagram) mirrors = helpers.get_mirrors(coxeter_diagram) P = Polychora(coxeter_matrix, mirrors, (1, 0, 0, 0)) P.build_geometry() write_to_pov(P) subprocess.call(POV_COMMAND, shell=True)
def render_star_polyhedra(coxeter_diagram, trunc_type, extra_relations=(), render_file="star-polyhedra.pov", output=None): coxeter_matrix = helpers.fill_matrix([x.numerator for x in coxeter_diagram]) mirrors = helpers.get_mirrors(coxeter_diagram) P = models.Polyhedra(coxeter_matrix, mirrors, trunc_type, extra_relations) _render_model(P, render_file, output)
def __init__(self): coxeter_diagram = (3, 2, 2, 3, 3, 2) coxeter_matrix = helpers.fill_matrix(coxeter_diagram) mirrors = helpers.get_mirrors(coxeter_diagram) super().__init__(coxeter_matrix, mirrors, (1, 1, 1, 1), extra_relations=()) self.symmetry_gens = tuple(range(6)) self.symmetry_rels = ((0,) * 3, (2,) * 3, (4,) * 3, (0, 2) * 2, (0, 4) * 2, (3, 4) * 2, (0, 1), (2, 3), (4, 5)) self.rotations = ((0,), (2,), (4,), (0, 2), (0, 4), (3, 4))
def render_polychora(coxeter_diagram, trunc_type, render_file, output=None): """ The main entrance for rendering 4d polychora. """ coxeter_matrix = helpers.fill_matrix(coxeter_diagram) mirrors = helpers.get_mirrors(coxeter_diagram) P = models.Polychora(coxeter_matrix, mirrors, trunc_type) _render_model(P, render_file, output)
def render_polyhedra(coxeter_diagram, trunc_type, render_file="polyhedra.pov", output=None, snub=False): """ The main entrance for rendering 3d polyhedra. """ coxeter_matrix = helpers.fill_matrix(coxeter_diagram) mirrors = helpers.get_mirrors(coxeter_diagram) if snub: P = models.Snub(coxeter_matrix, mirrors, trunc_type) else: P = models.Polyhedra(coxeter_matrix, mirrors, trunc_type) _render_model(P, render_file, output)
def anim(coxeter_diagram, trunc_type, description="polychora-rotation4d", glass_tex="NBglass", face_index=0, vertex_color="SkyBlue", edge_color="Orange", extra_relations=()): """Call POV-Ray to render the frames and FFmpeg to generate the movie. """ coxeter_matrix = helpers.fill_matrix([x.numerator for x in coxeter_diagram]) mirrors = helpers.get_mirrors(coxeter_diagram) P = Polychora(coxeter_matrix, mirrors, trunc_type, extra_relations) P.build_geometry() write_to_pov(P, glass_tex, face_index, vertex_color, edge_color) subprocess.call(POV_COMMAND.format(description), shell=True) subprocess.call(FFMPEG_COMMAND.format(description, description), shell=True)
def __init__(self, coxeter_diagram, init_dist, extra_relations=()): """ parameters ---------- :coxeter_diagram: Coxeter diagram for this polytope. :init_dist: distances between the initial vertex and the mirrors. :extra_relations: a presentation of a star polytope can be obtained by imposing more relations on the generators. For example "(ρ0ρ1ρ2ρ1)^n = 1" for some integer n, where n is the number of sides of a hole. See Coxeter's article "Regular skew polyhedra in three and four dimensions, and their topological analogues" """ # Coxeter matrix of the symmetry group self.coxeter_matrix = helpers.get_coxeter_matrix(coxeter_diagram) self.mirrors = helpers.get_mirrors(coxeter_diagram) # reflection transformations about the mirrors self.reflections = tuple(helpers.reflection_matrix(v) for v in self.mirrors) # the initial vertex self.init_v = helpers.get_init_point(self.mirrors, init_dist) # a mirror is active if and only if the initial vertex is off it self.active = tuple(bool(x) for x in init_dist) # generators of the symmetry group self.symmetry_gens = tuple(range(len(self.coxeter_matrix))) # relations between the generators self.symmetry_rels = tuple((i, j) * self.coxeter_matrix[i][j] for i, j in combinations(self.symmetry_gens, 2)) self.symmetry_rels += tuple(extra_relations) # to be calculated later self.vtable = None self.num_vertices = None self.vertex_coords = [] self.num_edges = None self.edge_indices = [] self.edge_coords = [] self.num_faces = None self.face_indices = [] self.face_coords = []
def __init__(self, upper_triangle, init_dist): # the Coxeter matrix self.coxeter_matrix = helpers.get_coxeter_matrix(upper_triangle) # the reflecting mirrors self._mirrors = helpers.get_mirrors(upper_triangle) # reflection transformations about the mirrors self._reflections = tuple( helpers.reflection_matrix(v) for v in self._mirrors) # coordinates of the initial vertex self.init_v = helpers.get_init_point(self._mirrors, init_dist) # a bool list holds if a mirror is active or not. self.active = tuple(bool(x) for x in init_dist) dim = len(self.coxeter_matrix) # generators of the Coxeter group self.symmetry_gens = tuple(range(dim)) # relations between the generators self.symmetry_rels = tuple( (i, j) * self.coxeter_matrix[i][j] for i, j in combinations(self.symmetry_gens, 2)) # to be calculated later self._vtable = None self.num_vertices = None self.vertex_coords = [] self.num_edges = None self.edge_indices = [] self.edge_coords = [] self.num_faces = None self.face_indices = [] self.face_coords = []