예제 #1
0
        // test for bounding box function
        public static void bbox_test(GLWindow g)
        {
            // draw a triangle
            Geo.Point p1 = new Geo.Point(0.1, 0.1, 0);
            Geo.Point p2 = new Geo.Point(0.8, 0.3, 0);
            Geo.Point p3 = new Geo.Point(0.2, 0.6, 0);
            GeoLine l1 = new GeoLine(p1, p2);
            GeoLine l2 = new GeoLine(p1, p3);
            GeoLine l3 = new GeoLine(p3, p2);
            l1.color = System.Drawing.Color.RoyalBlue;
            l2.color = System.Drawing.Color.RoyalBlue;
            l3.color = System.Drawing.Color.RoyalBlue;
            g.addGeom(l1);
            g.addGeom(l2);
            g.addGeom(l3);

            // create triangle and calculate bounding box
            Geo.Tri t = new Geo.Tri(p1, p2, p3);
            t.calc_bbox();
            Geo.Point a = new Geo.Point(t.bb.minx, t.bb.miny, 0);
            Geo.Point b = new Geo.Point(t.bb.maxx, t.bb.miny, 0);
            Geo.Point c = new Geo.Point(t.bb.maxx, t.bb.maxy, 0);
            Geo.Point d = new Geo.Point(t.bb.minx, t.bb.maxy, 0);
            GeoLine h1 = new GeoLine(a, b);
            GeoLine h2 = new GeoLine(b, c);
            GeoLine h3 = new GeoLine(c, d);
            GeoLine h4 = new GeoLine(d, a);
            h1.color = System.Drawing.Color.Red;
            h2.color = System.Drawing.Color.Red;
            h3.color = System.Drawing.Color.Red;
            h4.color = System.Drawing.Color.Red;
            g.addGeom(h1);
            g.addGeom(h2);
            g.addGeom(h3);
            g.addGeom(h4);

            // check that the points are OK
            GeoPoint v1 = new GeoPoint(t.bb.minx, t.bb.miny, 0);
            v1.color = System.Drawing.Color.Green;
            g.addGeom(v1);
            GeoPoint v2 = new GeoPoint(t.bb.maxx, t.bb.maxy, 0);
            v2.color = System.Drawing.Color.Azure;
            g.addGeom(v2);
        }
예제 #2
0
        // testing that the isinside function works OK
        public static void isinside_test(GLWindow g)
        {
            Random r = new Random();

            // generate lots of random points
            int N = 100;
            List<GeoPoint> points = new List<GeoPoint>();
            for (int n = 0; n < N; n++)
            {
                GeoPoint p = new GeoPoint(0.001 * (float)r.Next(0, 1000), 0.001 * (float)r.Next(0, 1000), 0);
                points.Add(p);
            }

            // draw a triangle
            Geo.Point p1 = new Geo.Point(0.1, 0.1, 0);
            Geo.Point p2 = new Geo.Point(0.8, 0.1, 0);
            Geo.Point p3 = new Geo.Point(0.2, 0.6, 0);
            GeoLine l1 = new GeoLine(p1, p2);
            GeoLine l2 = new GeoLine(p1, p3);
            GeoLine l3 = new GeoLine(p3, p2);
            l1.color = System.Drawing.Color.RoyalBlue;
            l2.color = System.Drawing.Color.RoyalBlue;
            l3.color = System.Drawing.Color.RoyalBlue;
            g.addGeom(l1);
            g.addGeom(l2);
            g.addGeom(l3);
            // p.color = System.Drawing.Color.Aqua;

            // draw points
            Geo.Tri t = new Geo.Tri(p2, p3, p1);
            foreach (GeoPoint p in points)
            {
                if (DropCutter.isinside(t,p.p))
                    p.color = System.Drawing.Color.Aqua;
                else
                    p.color = System.Drawing.Color.Red;

                g.addGeom(p);
            }
        }
예제 #3
0
 private void geoPointToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //System.Console.Write("adding GeoPoint!: ");
     GeoPoint p = new GeoPoint((double)RandomNumber(-10, 10), (double)RandomNumber(-10, 10), (double)RandomNumber(-10, 10));
     System.Console.WriteLine(p);
     p.color = System.Drawing.Color.Green;
     addGeom(p);
 }