Пример #1
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
 }
Пример #2
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
 }