Beispiel #1
0
        public void Tetrahedron(Polyhedron cube = null)
        {
            if (cube == null)
            {
                cube = new Polyhedron();
                cube.Hexahedron();
            }
            Polygon f0 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[0].Points[0]),
                new Point3D(cube.Polygons[1].Points[1]),
                new Point3D(cube.Polygons[1].Points[3])
            }
                );

            Polygon f1 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[1].Points[3]),
                new Point3D(cube.Polygons[1].Points[1]),
                new Point3D(cube.Polygons[0].Points[2])
            }
                );

            Polygon f2 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[0].Points[2]),
                new Point3D(cube.Polygons[1].Points[1]),
                new Point3D(cube.Polygons[0].Points[0])
            }
                );

            Polygon f3 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[0].Points[2]),
                new Point3D(cube.Polygons[0].Points[0]),
                new Point3D(cube.Polygons[1].Points[3])
            }
                );

            Polygons = new List <Polygon> {
                f0, f1, f2, f3
            };
            UpdateCenter();
        }
Beispiel #2
0
        private void button7_Click(object sender, EventArgs e)
        {
            List <Point3D> points = new List <Point3D>();
            var            lines  = textBox1.Text.Split('\n');

            foreach (var p in lines)
            {
                var arr = ((string)p).Split(',');
                points.Add(new Point3D(float.Parse(arr[0]), float.Parse(arr[1]), float.Parse(arr[2])));
            }

            Axis axis = 0;

            switch (comboBox6.SelectedItem.ToString())
            {
            case "OX":
                axis = 0;
                break;

            case "OY":
                axis = Axis.AXIS_Y;
                break;

            case "OZ":
                axis = Axis.AXIS_Z;
                break;

            default:
                axis = 0;
                break;
            }

            RotationFigure rotateFigure = new RotationFigure(points, axis, (int)numericUpDown23.Value);

            figure = rotateFigure;

            g.Clear(Color.White);
            if (clipping == 0)
            {
                rotateFigure.Show(g, 0);
            }
            else
            {
                show_z_buff();
            }
        }
Beispiel #3
0
        //DRAW FIGURE
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            {
            case 0:
                //Tetrahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Tetrahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else
                {
                    show_z_buff();
                }
                break;

            case 1:
                //Hexahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Hexahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else
                {
                    show_z_buff();
                }
                break;

            case 2:
                //Oktahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Octahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else
                {
                    show_z_buff();
                }
                break;

            case 3:
                //Icosahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Icosahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else
                {
                    show_z_buff();
                }
                break;

            case 4:
                //Dodecahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Dodecahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else
                {
                    show_z_buff();
                }
                break;

            default:
                break;
            }
        }
Beispiel #4
0
        public void Dodecahedron()
        {
            Polygons = new List <Polygon>();
            Polyhedron ik = new Polyhedron();

            ik.Icosahedron();

            List <Point3D> pts = new List <Point3D>();

            foreach (Polygon f in ik.Polygons)
            {
                pts.Add(f.Center);
            }

            Polygons.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[0]),
                new Point3D(pts[1]),
                new Point3D(pts[2]),
                new Point3D(pts[3]),
                new Point3D(pts[4])
            }));

            Polygons.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[5]),
                new Point3D(pts[6]),
                new Point3D(pts[7]),
                new Point3D(pts[8]),
                new Point3D(pts[9])
            }));

            for (int i = 0; i < 5; ++i)
            {
                Polygons.Add(new Polygon(new List <Point3D>
                {
                    new Point3D(pts[i]),
                    new Point3D(pts[(i + 1) % 5]),
                    new Point3D(pts[(i == 4) ? 10 : 2 * i + 12]),
                    new Point3D(pts[(i == 4) ? 11 : 2 * i + 13]),
                    new Point3D(pts[2 * i + 10])
                }));
            }

            Polygons.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[5]),
                new Point3D(pts[6]),
                new Point3D(pts[13]),
                new Point3D(pts[10]),
                new Point3D(pts[11])
            }));
            Polygons.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[6]),
                new Point3D(pts[7]),
                new Point3D(pts[15]),
                new Point3D(pts[12]),
                new Point3D(pts[13])
            }));
            Polygons.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[7]),
                new Point3D(pts[8]),
                new Point3D(pts[17]),
                new Point3D(pts[14]),
                new Point3D(pts[15])
            }));
            Polygons.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[8]),
                new Point3D(pts[9]),
                new Point3D(pts[19]),
                new Point3D(pts[16]),
                new Point3D(pts[17])
            }));
            Polygons.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[9]),
                new Point3D(pts[5]),
                new Point3D(pts[11]),
                new Point3D(pts[18]),
                new Point3D(pts[19])
            }));

            UpdateCenter();
        }
Beispiel #5
0
        public void Octahedron(Polyhedron cube = null)
        {
            if (cube == null)
            {
                cube = new Polyhedron();
                cube.Hexahedron();
            }

            Polygon f0 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[2].Center),
                new Point3D(cube.Polygons[1].Center),
                new Point3D(cube.Polygons[4].Center)
            }
                );

            Polygon f1 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[2].Center),
                new Point3D(cube.Polygons[1].Center),
                new Point3D(cube.Polygons[5].Center)
            }
                );

            Polygon f2 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[2].Center),
                new Point3D(cube.Polygons[5].Center),
                new Point3D(cube.Polygons[0].Center)
            }
                );

            Polygon f3 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[2].Center),
                new Point3D(cube.Polygons[0].Center),
                new Point3D(cube.Polygons[4].Center)
            }
                );

            Polygon f4 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[3].Center),
                new Point3D(cube.Polygons[1].Center),
                new Point3D(cube.Polygons[4].Center)
            }
                );

            Polygon f5 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[3].Center),
                new Point3D(cube.Polygons[1].Center),
                new Point3D(cube.Polygons[5].Center)
            }
                );

            Polygon f6 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[3].Center),
                new Point3D(cube.Polygons[5].Center),
                new Point3D(cube.Polygons[0].Center)
            }
                );

            Polygon f7 = new Polygon(
                new List <Point3D>
            {
                new Point3D(cube.Polygons[3].Center),
                new Point3D(cube.Polygons[0].Center),
                new Point3D(cube.Polygons[4].Center)
            }
                );

            Polygons = new List <Polygon> {
                f0, f1, f2, f3, f4, f5, f6, f7
            };
            UpdateCenter();
        }
Beispiel #6
0
 public Polyhedron(Polyhedron polyhedron)
 {
     Polygons = polyhedron.Polygons.Select(face => new Polygon(face)).ToList();
     Center   = new Point3D(polyhedron.Center);
 }