public static bool RayPlaneIntersection(out float t, Ray ray, Plane plane)
        {
            float dot = Vector3.Dot(ray.Dir, plane.Normal);
            if (System.Math.Abs(dot) < JiggleMath.Epsilon)
            {
                t = 0.0f;
                return false;
            }

            float dist = Distance.PointPlaneDistance(ray.Origin, plane);
            t = -dist / dot;
            return (t >= 0.0f);
        }
        public static bool LinePlaneIntersection(out float t, Line line, Plane plane)
        {
            float dot = Vector3.Dot(line.Dir, plane.Normal);

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

            float dist = Distance.PointPlaneDistance(line.Origin,plane);
            t = -dist / dot;
            return true;
        }
コード例 #3
0
 public Plane GetInverse()
 {
     Plane plane = new Plane(this.normal, this.d);
     plane.Invert();
     return plane;
 }
 public static bool SegmentPlaneIntersection(out float tS, Segment seg, Plane plane)
 {
     float denom = Vector3.Dot(plane.Normal, seg.Delta);
     if (System.Math.Abs(denom) > JiggleMath.Epsilon)
     {
         float 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
     {
         // parallel - return false even if it's in the plane
         tS = 0.0f;
         return false;
     }
 }
コード例 #5
0
 public override Primitive Clone()
 {
     Plane newPlane = new Plane(this.Normal, this.D);
     newPlane.Transform = Transform;
     return newPlane;
 }