示例#1
0
        // a function for displaying the normals in an STL file
        public static void draw_stl_normals(GLWindow g, STLSurf s)
        {
            // draw triangle normas
            foreach (Geo.Tri t in s.tris)
            {
                // from STL file
                Geo.Point p1 = new Geo.Point(t.p[0].x, t.p[0].y, t.p[0].z);
                Geo.Point p2 = new Geo.Point(t.p[0].x + t.n.x, t.p[0].y + t.n.y, t.p[0].z + t.n.z);
                GeoLine l = new GeoLine(p1, p2);
                l.color = System.Drawing.Color.Green;
                g.addGeom(l);

                // calculate yourself:
                Vector v1 = new Vector(t.p[0].x - t.p[1].x, t.p[0].y - t.p[1].y, t.p[0].z - t.p[1].z);
                Vector v2 = new Vector(t.p[0].x - t.p[2].x, t.p[0].y - t.p[2].y, t.p[0].z - t.p[2].z);
                Vector n;
                n = v1.Cross(v2); // the normal is in the direction of the cross product between the edge vectors
                n = (1 / n.Length()) * n; // normalize to length==1
                p1 = new Geo.Point(t.p[0].x, t.p[0].y, t.p[0].z);
                p2 = new Geo.Point(t.p[0].x + n.x, t.p[0].y + n.y, t.p[0].z + n.z);
                l = new GeoLine(p1, p2);
                l.color = System.Drawing.Color.Blue;
                g.addGeom(l);

            }
        }
示例#2
0
 public void recalc_normals()
 {
     // normal data from STL files is usually junk, so recalculate:
     Vector v1 = new Vector(p[0].x - p[1].x, p[0].y - p[1].y, p[0].z - p[1].z);
     Vector v2 = new Vector(p[0].x - p[2].x, p[0].y - p[2].y, p[0].z - p[2].z);
     n = v1.Cross(v2); // the normal is in the direction of the cross product between the edge vectors
     n = (1 / n.Length()) * n; // normalize to length==1
 }
示例#3
0
        public void pan_lr(double amount)
        {
            // move cen to the left
            Vector v = up.Cross(eye - cen);

            v.normalize();
            amount = 0.001 * amount * _r;
            cen.x += amount * v.x;
            cen.y += amount * v.y;
            cen.z += amount * v.z;
            recalc();
        }
示例#4
0
 public Tri(Point P1, Point P2, Point P3)
 {
     p = new Point[3];
     bb = new Bbox();
     p[0] = P1;
     p[1] = P2;
     p[2] = P3;
     // if normal is not given, calculate it here.
     Vector v1 = new Vector(p[0].x - p[1].x, p[0].y - p[1].y, p[0].z - p[1].z);
     Vector v2 = new Vector(p[0].x - p[2].x, p[0].y - p[2].y, p[0].z - p[2].z);
     n = v1.Cross(v2); // the normal is in the direction of the cross product between the edge vectors
     n = (1 / n.Length()) * n; // normalize to length==1
 }
示例#5
0
        private void recalc()
        {
            // recalculate eye position
            eye.x = cen.x + _r * Math.Cos(_theta) * Math.Sin(_fi);
            eye.y = cen.y + _r * Math.Sin(_theta) * Math.Sin(_fi);
            eye.z = cen.z + _r * Math.Cos(_fi);

            // recalculate up-vector
            Vector n = new Vector(Math.Sin(_theta), -Math.Cos(_theta), 0);

            up = n.Cross(eye - cen);
            up.normalize();
            // System.Console.WriteLine("Camera: cen=" + cen + " eye=" + eye);
        }
示例#6
0
文件: Geo.cs 项目: dharani811/monocam
 public void recalc_normals()
 {
     // normal data from STL files is usually junk, so recalculate:
        Vector v1 = new Vector(p[0].x - p[1].x, p[0].y - p[1].y, p[0].z - p[1].z);
        Vector v2 = new Vector(p[0].x - p[2].x, p[0].y - p[2].y, p[0].z- p[2].z);
        n = v1.Cross(v2); // the normal is in the direction of the cross product between the edge vectors
        n = (1 / n.Length()) * n; // normalize to length==1
 }
示例#7
0
文件: Geo.cs 项目: dharani811/monocam
 public Tri(Point P1, Point P2, Point P3)
 {
     p = new Point[3];
        bb = new Bbox();
        p[0] = P1;
        p[1] = P2;
        p[2] = P3;
        // if normal is not given, calculate it here.
        Vector v1 = new Vector(p[0].x - p[1].x, p[0].y - p[1].y, p[0].z - p[1].z);
        Vector v2 = new Vector(p[0].x - p[2].x, p[0].y - p[2].y, p[0].z- p[2].z);
        n = v1.Cross(v2); // the normal is in the direction of the cross product between the edge vectors
        n = (1 / n.Length()) * n; // normalize to length==1
 }