Ejemplo n.º 1
0
        public static void Intersects(ref BoundingSphere2 boundingSphere, ref BoundingBox2 boundingBox, out bool result)
        {
            Vector2 clampedLocation;

            if (boundingSphere.Center.X > boundingBox.Max.X)
            {
                clampedLocation.X = boundingBox.Max.X;
            }
            else if (boundingSphere.Center.X < boundingBox.Min.X)
            {
                clampedLocation.X = boundingBox.Min.X;
            }
            else
            {
                clampedLocation.X = boundingSphere.Center.X;
            }

            if (boundingSphere.Center.Y > boundingBox.Max.Y)
            {
                clampedLocation.Y = boundingBox.Max.Y;
            }
            else if (boundingSphere.Center.Y < boundingBox.Min.Y)
            {
                clampedLocation.Y = boundingBox.Min.Y;
            }
            else
            {
                clampedLocation.Y = boundingSphere.Center.Y;
            }

            result = clampedLocation.DistanceSquared(boundingSphere.Center) <= (boundingSphere.Radius * boundingSphere.Radius);
        }
Ejemplo n.º 2
0
        public bool Intersects(BoundingBox2 boundingBox)
        {
            Vector2 clampedLocation;
            if (Center.X > boundingBox.Max.X)
            {
                clampedLocation.X = boundingBox.Max.X;
            }
            else if (Center.X < boundingBox.Min.X)
            {
                clampedLocation.X = boundingBox.Min.X;
            }
            else
            {
                clampedLocation.X = Center.X;
            }

            if (Center.Y > boundingBox.Max.Y)
            {
                clampedLocation.Y = boundingBox.Max.Y;
            }
            else if (Center.Y < boundingBox.Min.Y)
            {
                clampedLocation.Y = boundingBox.Min.Y;
            }
            else
            {
                clampedLocation.Y = Center.Y;
            }

            return clampedLocation.DistanceSquared(Center) <= (Radius * Radius);
        }
Ejemplo n.º 3
0
        public bool Intersects(BoundingBox2 boundingBox)
        {
            Vector2 clampedLocation;

            if (Center.X > boundingBox.Max.X)
            {
                clampedLocation.X = boundingBox.Max.X;
            }
            else if (Center.X < boundingBox.Min.X)
            {
                clampedLocation.X = boundingBox.Min.X;
            }
            else
            {
                clampedLocation.X = Center.X;
            }

            if (Center.Y > boundingBox.Max.Y)
            {
                clampedLocation.Y = boundingBox.Max.Y;
            }
            else if (Center.Y < boundingBox.Min.Y)
            {
                clampedLocation.Y = boundingBox.Min.Y;
            }
            else
            {
                clampedLocation.Y = Center.Y;
            }

            return(clampedLocation.DistanceSquared(Center) <= (Radius * Radius));
        }
Ejemplo n.º 4
0
        public static void Intersects(ref BoundingSphere2 boundingSphere, ref BoundingBox2 boundingBox, out bool result)
        {
            Vector2 clampedLocation;
            if (boundingSphere.Center.X > boundingBox.Max.X)
            {
                clampedLocation.X = boundingBox.Max.X;
            }
            else if (boundingSphere.Center.X < boundingBox.Min.X)
            {
                clampedLocation.X = boundingBox.Min.X;
            }
            else
            {
                clampedLocation.X = boundingSphere.Center.X;
            }

            if (boundingSphere.Center.Y > boundingBox.Max.Y)
            {
                clampedLocation.Y = boundingBox.Max.Y;
            }
            else if (boundingSphere.Center.Y < boundingBox.Min.Y)
            {
                clampedLocation.Y = boundingBox.Min.Y;
            }
            else
            {
                clampedLocation.Y = boundingSphere.Center.Y;
            }

            result = clampedLocation.DistanceSquared(boundingSphere.Center) <= (boundingSphere.Radius * boundingSphere.Radius);
        }
Ejemplo n.º 5
0
        public BoundingBox2 Merge(BoundingBox2 boundingBox2)
        {
            BoundingBox2 result;

            if (Min.X < boundingBox2.Min.X)
            {
                result.Min.X = Min.X;
            }
            else
            {
                result.Min.X = boundingBox2.Min.X;
            }

            if (Min.Y < boundingBox2.Min.Y)
            {
                result.Min.Y = Min.Y;
            }
            else
            {
                result.Min.Y = boundingBox2.Min.Y;
            }

            if (Max.X > boundingBox2.Max.X)
            {
                result.Max.X = Max.X;
            }
            else
            {
                result.Max.X = boundingBox2.Max.X;
            }

            if (Max.Y > boundingBox2.Max.Y)
            {
                result.Max.Y = Max.Y;
            }
            else
            {
                result.Max.Y = boundingBox2.Max.Y;
            }

            return(result);
        }
Ejemplo n.º 6
0
        public static void Merge(ref BoundingBox2 boundingBox1, ref BoundingBox2 boundingBox2, out BoundingBox2 result)
        {
            if (boundingBox1.Min.X < boundingBox2.Min.X)
            {
                result.Min.X = boundingBox1.Min.X;
            }
            else
            {
                result.Min.X = boundingBox2.Min.X;
            }

            if (boundingBox1.Min.Y < boundingBox2.Min.Y)
            {
                result.Min.Y = boundingBox1.Min.Y;
            }
            else
            {
                result.Min.Y = boundingBox2.Min.Y;
            }

            if (boundingBox1.Max.X > boundingBox2.Max.X)
            {
                result.Max.X = boundingBox1.Max.X;
            }
            else
            {
                result.Max.X = boundingBox2.Max.X;
            }

            if (boundingBox1.Max.Y > boundingBox2.Max.Y)
            {
                result.Max.Y = boundingBox1.Max.Y;
            }
            else
            {
                result.Max.Y = boundingBox2.Max.Y;
            }
        }
Ejemplo n.º 7
0
 public static void Intersects(ref BoundingBox2 boundingBox1, ref BoundingBox2 boundingBox2, out bool result)
 {
     result =
         !(boundingBox1.Min.X > boundingBox2.Max.X || boundingBox1.Min.Y > boundingBox2.Max.Y ||
           boundingBox2.Min.X > boundingBox1.Max.X || boundingBox2.Min.Y > boundingBox1.Max.Y);
 }
Ejemplo n.º 8
0
        public BoundingBox2 Merge(BoundingBox2 boundingBox2)
        {
            BoundingBox2 result;
            if (Min.X < boundingBox2.Min.X) result.Min.X = Min.X;
            else result.Min.X = boundingBox2.Min.X;

            if (Min.Y < boundingBox2.Min.Y) result.Min.Y = Min.Y;
            else result.Min.Y = boundingBox2.Min.Y;

            if (Max.X > boundingBox2.Max.X) result.Max.X = Max.X;
            else result.Max.X = boundingBox2.Max.X;

            if (Max.Y > boundingBox2.Max.Y) result.Max.Y = Max.Y;
            else result.Max.Y = boundingBox2.Max.Y;

            return result;
        }
Ejemplo n.º 9
0
 public bool Intersects(BoundingBox2 boundingBox)
 {
     return
         !(boundingBox.Min.X > Max.X || boundingBox.Min.Y > Max.Y ||
           Min.X > boundingBox.Max.X || Min.Y > boundingBox.Max.Y);
 }
Ejemplo n.º 10
0
        public static void Merge(ref BoundingBox2 boundingBox1, ref BoundingBox2 boundingBox2, out BoundingBox2 result)
        {
            if (boundingBox1.Min.X < boundingBox2.Min.X) result.Min.X = boundingBox1.Min.X;
            else result.Min.X = boundingBox2.Min.X;

            if (boundingBox1.Min.Y < boundingBox2.Min.Y) result.Min.Y = boundingBox1.Min.Y;
            else result.Min.Y = boundingBox2.Min.Y;

            if (boundingBox1.Max.X > boundingBox2.Max.X) result.Max.X = boundingBox1.Max.X;
            else result.Max.X = boundingBox2.Max.X;

            if (boundingBox1.Max.Y > boundingBox2.Max.Y) result.Max.Y = boundingBox1.Max.Y;
            else result.Max.Y = boundingBox2.Max.Y;
        }
Ejemplo n.º 11
0
 public void Intersects(BoundingBox2 boundingBox, out bool result)
 {
     result = X >= boundingBox.Left && X <= boundingBox.Right && Y >= boundingBox.Bottom && Y <= boundingBox.Top;
 }
Ejemplo n.º 12
0
 public bool Intersects(BoundingBox2 boundingBox)
 {
     return(X >= boundingBox.Left && X <= boundingBox.Right && Y >= boundingBox.Bottom && Y <= boundingBox.Top);
 }
Ejemplo n.º 13
0
 public static void Intersects(ref BoundingBox2 boundingBox1, ref BoundingBox2 boundingBox2, out bool result)
 {
     result =
         !(boundingBox1.Min.X > boundingBox2.Max.X || boundingBox1.Min.Y > boundingBox2.Max.Y ||
           boundingBox2.Min.X > boundingBox1.Max.X || boundingBox2.Min.Y > boundingBox1.Max.Y);
 }
Ejemplo n.º 14
0
 public bool Intersects(BoundingBox2 boundingBox)
 {
     return
         (!(boundingBox.Min.X > Max.X || boundingBox.Min.Y > Max.Y ||
            Min.X > boundingBox.Max.X || Min.Y > boundingBox.Max.Y));
 }