示例#1
0
        public Intersections _IntersectLocal(Ray ray)
        {
            var dirCrossE2 = ray.Direction * E2;
            var det        = E1.DotProduct(dirCrossE2);

            if (Math.Abs(det) < Helper.Epsilon)
            {
                return(new Intersections());
            }

            var f          = 1.0 / det;
            var p1ToOrigin = ray.Origin - P1;
            var u          = f * p1ToOrigin.DotProduct(dirCrossE2);

            if (u < 0 || u > 1)
            {
                return(new Intersections());
            }

            var originCrossE1 = p1ToOrigin * E1;
            var v             = f * ray.Direction.DotProduct(originCrossE1);

            if (v < 0 || (u + v) > 1)
            {
                return(new Intersections());
            }

            var t = f * E2.DotProduct(originCrossE1);

            return(new Intersections {
                new Intersection(t, this, u, v)
            });
        }