コード例 #1
0
        private void Button3_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();

            form2.ShowDialog();

            var   f             = form2.f;
            float x0            = form2.X0;
            float x1            = form2.X1;
            float y0            = form2.Y0;
            float y1            = form2.Y1;
            int   cnt_of_breaks = form2.Cnt_of_breaks;

            form2.Dispose();

            ReverseFloatComparer fcmp = new ReverseFloatComparer();

            float dx = (Math.Abs(x0) + Math.Abs(x1)) / cnt_of_breaks;
            float dy = (Math.Abs(y0) + Math.Abs(y1)) / cnt_of_breaks;

            List <Face>    faces = new List <Face>();
            List <Point3d> pts0  = new List <Point3d>();
            List <Point3d> pts1  = new List <Point3d>();

            for (float x = x0; x < x1; x += dx)
            {
                for (float y = y0; y < y1; y += dy)
                {
                    float z = f(x, y);
                    pts1.Add(new Point3d(x, y, z));
                }
                if (pts0.Count != 0)
                {
                    for (int i = 1; i < pts0.Count; ++i)
                    {
                        faces.Add(new Face(new List <Point3d>()
                        {
                            new Point3d(pts0[i - 1]), new Point3d(pts1[i - 1]),
                            new Point3d(pts1[i]), new Point3d(pts0[i])
                        }));
                    }
                }
                pts0.Clear();
                pts0 = pts1;
                pts1 = new List <Point3d>();
            }

            g.Clear(Color.White);
            figure = new Polyhedron(faces);
            figure.Apply(Transformation.Scale(5, 5, 5));
            figure.show(g, pr, new_fig);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Molkree/ComputerGraphics
        //// graphic
        //private void button4_Click_1(object sender, EventArgs e)
        //{
        //    Form2 form2 = new Form2();
        //    form2.ShowDialog();

        //    var f = form2.f;
        //    float x0 = form2.X0;
        //    float x1 = form2.X1;
        //    float y0 = form2.Y0;
        //    float y1 = form2.Y1;
        //    int cnt_of_breaks = form2.Cnt_of_breaks;

        //    form2.Dispose();

        //    float dx = (Math.Abs(x0) + Math.Abs(x1)) / cnt_of_breaks;
        //    float dy = (Math.Abs(y0) + Math.Abs(y1)) / cnt_of_breaks;

        //    List<Face> faces = new List<Face>();
        //    List<Point3d> pts0 = new List<Point3d>();
        //    List<Point3d> pts1 = new List<Point3d>();

        //    for (float x = x0; x < x1; x += dx)
        //    {
        //        for (float y = y0; y < y1; y += dy)
        //        {
        //            float z = f(x, y);
        //            pts1.Add(new Point3d(x, y, z));
        //        }
        //        // make faces
        //        if (pts0.Count != 0)
        //            for (int i = 1; i < pts0.Count; ++i)
        //            {
        //                faces.Add(new Face(new List<Point3d>() {
        //                    new Point3d(pts0[i - 1]), new Point3d(pts1[i - 1]),
        //                    new Point3d(pts1[i]), new Point3d(pts0[i])
        //                }));
        //            }
        //        pts0.Clear();
        //        pts0 = pts1;
        //        pts1 = new List<Point3d>();
        //    }

        //    g.Clear(Color.White);
        //    figure = new Polyhedron(faces);
        //    figure.show(g, pr, new_fig);
        //}

        // graphic
        private void button4_Click_1(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();

            form2.ShowDialog();

            var   f             = form2.f;
            float x0            = form2.X0;
            float x1            = form2.X1;
            float y0            = form2.Y0;
            float y1            = form2.Y1;
            int   cnt_of_breaks = form2.Cnt_of_breaks;

            form2.Dispose();

            ReverseFloatComparer fcmp = new ReverseFloatComparer();

            float dx = (Math.Abs(x0) + Math.Abs(x1)) / cnt_of_breaks;
            float dy = (Math.Abs(y0) + Math.Abs(y1)) / cnt_of_breaks;

            List <Face>    faces = new List <Face>();
            List <Point3d> pts0  = new List <Point3d>();
            List <Point3d> pts1  = new List <Point3d>();

            //SortedDictionary<float, PointF> graph_function = new SortedDictionary<float, PointF>(fcmp); // z, (x, y)

            for (float x = x0; x < x1; x += dx)
            {
                for (float y = y0; y < y1; y += dy)
                {
                    float z = f(x, y);
                    //graph_function.Add(z, new PointF(x, y));
                    pts1.Add(new Point3d(x, y, z));
                }
                // make faces
                if (pts0.Count != 0)
                {
                    for (int i = 1; i < pts0.Count; ++i)
                    {
                        faces.Add(new Face(new List <Point3d>()
                        {
                            new Point3d(pts0[i - 1]), new Point3d(pts1[i - 1]),
                            new Point3d(pts1[i]), new Point3d(pts0[i])
                        }));
                    }
                }
                pts0.Clear();
                pts0 = pts1;
                pts1 = new List <Point3d>();
            }

            g.Clear(Color.White);
            figure                = new Polyhedron(faces);
            figure.is_graph       = true;
            figure.graph_function = f;

            //figure.graph_function = graph_function;
            figure.show(g, pr, new_fig);
            //figure.show_camera(g_camera, camera.view, new_fig);
            create_camera();
        }