Exemple #1
0
 public static Bounding.Box Transform(Bounding.Box bounding, Matrix transformation)
 {
     return(new Bounding.Box
     {
         LocalBoundingBox = bounding.LocalBoundingBox,
         Transformation = bounding.Transformation * transformation
     });
 }
Exemple #2
0
        public static bool Intersect(Bounding.Box a, Bounding.Line b, out object intersection)
        {
            intersection = null;

            Vector3         v    = b.P1 - b.P0;
            RayIntersection rOut = new RayIntersection();

            return(Intersect(a, new Ray(b.P0, Vector3.Normalize(v)), out rOut) && rOut.Distance < v.Length());
        }
Exemple #3
0
        // ----------------------------------------------------------------------------------------------
        // -- Box ---------------------------------------------------------------------------------------
        // ----------------------------------------------------------------------------------------------

        public static bool Intersect(Bounding.Box a, Ray b, out object intersection)
        {
            var r = new RayIntersection();

            intersection = r;
            Matrix invTransformation = Matrix.Invert(a.Transformation);
            var    newRay            = new Ray(
                Vector3.TransformCoordinate(b.Position, invTransformation),
                Vector3.Normalize(Vector3.TransformNormal(b.Direction, invTransformation)));

            bool hit = BoundingBox.Intersects(a.LocalBoundingBox, newRay, out r.Distance);

            if (hit)
            {
                var newPos = Vector3.TransformCoordinate(newRay.Position + newRay.Direction * r.Distance,
                                                         a.Transformation);
                r.Distance = (newPos - b.Position).Length();
            }
            return(hit);
        }
Exemple #4
0
 public static bool Intersect(RectangleF a, Bounding.Box b, out object intersection)
 {
     return(Intersect(a, b.ToContainerBox(), out intersection));
 }
Exemple #5
0
 public static BoundingBox BoundingToBox(Bounding.Box a)
 {
     return(a.ToContainerBox());
 }
 public static RSpatialRelation Relation(RectangleF a, Bounding.Box b)
 {
     return(Relation(a, BoundingBoxToRectangleF(b.ToContainerBox())));
 }