Beispiel #1
0
        public static void Intersects(ref Vector3 vector, ref Triangle3 triangle, out bool result)
        {
            var v0 = triangle.Point2 - triangle.Point1;
            var v1 = triangle.Point3 - triangle.Point1;
            var v2 = vector - triangle.Point1;

            float dot00 = v0.Dot();
            float dot01 = v0.Dot(v1);
            float dot02 = v0.Dot(v2);
            float dot11 = v1.Dot();
            float dot12 = v1.Dot(v2);

            float invDenom = 1 / ((dot00 * dot11) - (dot01 * dot01));
            float u        = ((dot11 * dot02) - (dot01 * dot12)) * invDenom;
            float v        = ((dot00 * dot12) - (dot01 * dot02)) * invDenom;

            result = (u > 0) && (v > 0) && ((u + v) < 1);
        }
Beispiel #2
0
        public bool Intersects(Triangle3 triangle)
        {
            var v0 = triangle.Point2 - triangle.Point1;
            var v1 = triangle.Point3 - triangle.Point1;
            var v2 = this - triangle.Point1;

            float dot00 = v0.Dot();
            float dot01 = v0.Dot(v1);
            float dot02 = v0.Dot(v2);
            float dot11 = v1.Dot();
            float dot12 = v1.Dot(v2);

            float invDenom = 1 / ((dot00 * dot11) - (dot01 * dot01));
            float u        = ((dot11 * dot02) - (dot01 * dot12)) * invDenom;
            float v        = ((dot00 * dot12) - (dot01 * dot02)) * invDenom;

            return((u > 0) && (v > 0) && ((u + v) < 1));
        }
Beispiel #3
0
        public bool Intersects(Triangle3 triangle)
        {
            var v0 = triangle.Point2 - triangle.Point1;
            var v1 = triangle.Point3 - triangle.Point1;
            var v2 = this - triangle.Point1;

            float dot00 = v0.Dot();
            float dot01 = v0.Dot(v1);
            float dot02 = v0.Dot(v2);
            float dot11 = v1.Dot();
            float dot12 = v1.Dot(v2);

            float invDenom = 1 / ((dot00*dot11) - (dot01*dot01));
            float u = ((dot11*dot02) - (dot01*dot12)) * invDenom;
            float v = ((dot00*dot12) - (dot01*dot02)) * invDenom;
            return (u>0) && (v>0) && ((u+v) < 1);
        }
Beispiel #4
0
        public static void Intersects(ref Vector3 vector, ref Triangle3 triangle, out bool result)
        {
            var v0 = triangle.Point2 - triangle.Point1;
            var v1 = triangle.Point3 - triangle.Point1;
            var v2 = vector - triangle.Point1;

            float dot00 = v0.Dot();
            float dot01 = v0.Dot(v1);
            float dot02 = v0.Dot(v2);
            float dot11 = v1.Dot();
            float dot12 = v1.Dot(v2);

            float invDenom = 1 / ((dot00*dot11) - (dot01*dot01));
            float u = ((dot11*dot02) - (dot01*dot12)) * invDenom;
            float v = ((dot00*dot12) - (dot01*dot02)) * invDenom;
            result = (u>0) && (v>0) && ((u+v) < 1);
        }
Beispiel #5
0
        public static void Normal(ref Triangle3 triangle, out Vector3 result)
        {
            Vector3 vector1 = (triangle.Point1 - triangle.Point2), vector2 = (triangle.Point3 - triangle.Point1);

            result = new Vector3(-((vector1.Y * vector2.Z) - (vector1.Z * vector2.Y)), -((vector1.Z * vector2.X) - (vector1.X * vector2.Z)), -((vector1.X * vector2.Y) - (vector1.Y * vector2.X))).Normalize();
        }
Beispiel #6
0
 public static void Normal(ref Triangle3 triangle, out Vector3 result)
 {
     Vector3 vector1 = (triangle.Point1-triangle.Point2), vector2 = (triangle.Point3-triangle.Point1);
     result = new Vector3(-((vector1.Y*vector2.Z) - (vector1.Z*vector2.Y)), -((vector1.Z*vector2.X) - (vector1.X*vector2.Z)), -((vector1.X*vector2.Y) - (vector1.Y*vector2.X))).Normalize();
 }