Exemple #1
0
        public Triangle(Point a, Point b, Point c)
        {
            _a = a;
              _b = b;
              _c = c;

              Vector tmp1 = new Vector(a, b);
              Vector tmp2 = new Vector(a, c);
              _polyNormal = tmp1.CrossProduct(tmp2);
              _polyNormal.Normalise();

              CalculatePolygonCenter();
        }
Exemple #2
0
        private void CalculatePolygonCenter()
        {
            Point milieu;
              Vector v1;
              Vector v2;

              //Le CENTRE DE GRAVITE du polygone est situe au 2/3 d'une des medianes
              //Nous allons tracer la mediane a partir du pts[0]. il nous faut donc
              //le point milieu du segment pts[1],pts[2]
              v1 = new Vector(_b, _c);
              v1.DivideBy(2);

              v2 = new Vector(_b.X, _b.Y, _b.Z);
              v2.AddVector(v1);

              milieu = new Point(v2.X, v2.Y, v2.Z);

              //Trouvons la mediane
              v1 = new Vector(_a, milieu);
              v1.MultiplyBy(2 / 3);

              v2 = new Vector(_a.X, _a.Y, _a.Z);
              v2.AddVector(v1);

              _polyCenter = new Point(v2.X, v2.Y, v2.Z);
        }
Exemple #3
0
        public bool IsFrontFacing(Triangle triangle)
        {
            // on prend en compte que les normales sont unitaires...
              double dot = _polyNormal.DotProduct(triangle._polyNormal);

              Vector vecProj = new Vector(_polyNormal);
              vecProj.MultiplyBy(dot);
              vecProj.Normalise();

              vecProj.AddVector(_polyNormal);
              vecProj.Normalise();

              if(vecProj.Norm >= -Definition.EPSILON && vecProj.Norm <= Definition.EPSILON)
            return false;
              else
            return true;
        }
Exemple #4
0
 public double DotProduct(Vector vec)
 {
     return _x * vec._x + _y * vec._y + _z * vec._z;
 }
Exemple #5
0
 public Vector CrossProduct(Vector vec)
 {
     return new Vector(_y * vec._z - _z * vec._y, _z * vec._x - _x * vec._z, _x * vec._y - _y * vec._x);
 }
Exemple #6
0
 public void AddVector(Vector vec)
 {
     _x += vec._x;
       _y += vec._y;
       _z += vec._z;
 }
Exemple #7
0
 public Vector(Vector vec)
 {
     _x = vec._x;
       _y = vec._y;
       _z = vec._z;
 }