public void show(Graphics g, Projection pr = 0, Pen pen = null, bool normal = false, Point3d camera = null) { var figure = new Polyhedron(this); figure.Apply(Transformation.ProjectionTransform(pr)); foreach (Face f in figure.Faces) { if(normal) if(camera == null) f.find_normal(this.Center); else f.find_normal(this.Center, camera); if (f.IsVisible) f.show(g, pr, pen); } }
public Polyhedron(Polyhedron polyhedron) { Faces = polyhedron.Faces.Select(face => new Face(face)).ToList(); Center = new Point3d(polyhedron.Center); Cube_size = polyhedron.Cube_size; }
public void make_octahedron(Polyhedron cube = null) { if (cube == null) { cube = new Polyhedron(); cube.make_hexahedron(); } // up Face f0 = new Face( new List<Point3d> { new Point3d(cube.Faces[2].Center), new Point3d(cube.Faces[1].Center), new Point3d(cube.Faces[4].Center) } ); Face f1 = new Face( new List<Point3d> { new Point3d(cube.Faces[2].Center), new Point3d(cube.Faces[1].Center), new Point3d(cube.Faces[5].Center) } ); Face f2 = new Face( new List<Point3d> { new Point3d(cube.Faces[2].Center), new Point3d(cube.Faces[5].Center), new Point3d(cube.Faces[0].Center) } ); Face f3 = new Face( new List<Point3d> { new Point3d(cube.Faces[2].Center), new Point3d(cube.Faces[0].Center), new Point3d(cube.Faces[4].Center) } ); // down Face f4 = new Face( new List<Point3d> { new Point3d(cube.Faces[3].Center), new Point3d(cube.Faces[1].Center), new Point3d(cube.Faces[4].Center) } ); Face f5 = new Face( new List<Point3d> { new Point3d(cube.Faces[3].Center), new Point3d(cube.Faces[1].Center), new Point3d(cube.Faces[5].Center) } ); Face f6 = new Face( new List<Point3d> { new Point3d(cube.Faces[3].Center), new Point3d(cube.Faces[5].Center), new Point3d(cube.Faces[0].Center) } ); Face f7 = new Face( new List<Point3d> { new Point3d(cube.Faces[3].Center), new Point3d(cube.Faces[0].Center), new Point3d(cube.Faces[4].Center) } ); Faces = new List<Face> { f0, f1, f2, f3, f4, f5, f6, f7 }; find_center(); }