Example #1
0
        public static bool RayPlaneIntersection(out float t, Ray ray, Plane plane)
        {
            var dot = Vector3.Dot(ray.Dir, plane.Normal);

            if (System.Math.Abs(dot) < JiggleMath.Epsilon)
            {
                t = 0.0f;
                return(false);
            }

            var dist = Distance.PointPlaneDistance(ray.Origin, plane);

            t = -dist / dot;
            return(t >= 0.0f);
        }
Example #2
0
        public static bool SegmentPlaneIntersection(out float tS, Segment seg, Plane plane)
        {
            var denom = Vector3.Dot(plane.Normal, seg.Delta);

            if (System.Math.Abs(denom) > JiggleMath.Epsilon)
            {
                var t = -(Vector3.Dot(plane.Normal, seg.Origin) + plane.D) / denom;
                if (t < 0.0f || t > 1.0f)
                {
                    tS = 0.0f;
                    return(false);
                }

                tS = t;
                return(true);
            }
            else
            {
                tS = 0.0f;
                return(false);
            }
        }