Esempio n. 1
0
 /// <summary>
 /// Gets whether or not a specified <see cref="BoundingBox"/> intersects with this sphere.
 /// </summary>
 /// <param name="box">The box for testing.</param>
 /// <param name="result"><c>true</c> if <see cref="BoundingBox"/> intersects with this sphere; <c>false</c> otherwise. As an output parameter.</param>
 public void Intersects(ref BoundingBox box, out bool result)
 {
     box.Intersects(ref this, out result);
 }
Esempio n. 2
0
        public static ContainmentType Contains(BoundingSphere sphere, BoundingBox box)
        {
            Vector3 vector;

            if (!BoundingBox.Intersects(box, sphere))
            {
                return(ContainmentType.Disjoint);
            }

            float radius = sphere.Radius * sphere.Radius;

            vector.X = sphere.Center.X - box.Minimum.X;
            vector.Y = sphere.Center.Y - box.Maximum.Y;
            vector.Z = sphere.Center.Z - box.Maximum.Z;

            if (vector.LengthSquared() > radius)
            {
                return(ContainmentType.Intersects);
            }

            vector.X = sphere.Center.X - box.Maximum.X;
            vector.Y = sphere.Center.Y - box.Maximum.Y;
            vector.Z = sphere.Center.Z - box.Maximum.Z;

            if (vector.LengthSquared() > radius)
            {
                return(ContainmentType.Intersects);
            }

            vector.X = sphere.Center.X - box.Maximum.X;
            vector.Y = sphere.Center.Y - box.Minimum.Y;
            vector.Z = sphere.Center.Z - box.Maximum.Z;

            if (vector.LengthSquared() > radius)
            {
                return(ContainmentType.Intersects);
            }

            vector.X = sphere.Center.X - box.Minimum.X;
            vector.Y = sphere.Center.Y - box.Minimum.Y;
            vector.Z = sphere.Center.Z - box.Maximum.Z;

            if (vector.LengthSquared() > radius)
            {
                return(ContainmentType.Intersects);
            }

            vector.X = sphere.Center.X - box.Minimum.X;
            vector.Y = sphere.Center.Y - box.Maximum.Y;
            vector.Z = sphere.Center.Z - box.Minimum.Z;

            if (vector.LengthSquared() > radius)
            {
                return(ContainmentType.Intersects);
            }

            vector.X = sphere.Center.X - box.Maximum.X;
            vector.Y = sphere.Center.Y - box.Maximum.Y;
            vector.Z = sphere.Center.Z - box.Minimum.Z;

            if (vector.LengthSquared() > radius)
            {
                return(ContainmentType.Intersects);
            }

            vector.X = sphere.Center.X - box.Maximum.X;
            vector.Y = sphere.Center.Y - box.Minimum.Y;
            vector.Z = sphere.Center.Z - box.Minimum.Z;

            if (vector.LengthSquared() > radius)
            {
                return(ContainmentType.Intersects);
            }

            vector.X = sphere.Center.X - box.Minimum.X;
            vector.Y = sphere.Center.Y - box.Minimum.Y;
            vector.Z = sphere.Center.Z - box.Minimum.Z;

            if (vector.LengthSquared() > radius)
            {
                return(ContainmentType.Intersects);
            }

            return(ContainmentType.Contains);
        }
Esempio n. 3
0
 /// <summary>
 /// Gets whether or not a specified <see cref="BoundingBox"/> intersects with this sphere.
 /// </summary>
 /// <param name="box">The box for testing.</param>
 /// <returns><c>true</c> if <see cref="BoundingBox"/> intersects with this sphere; <c>false</c> otherwise.</returns>
 public bool Intersects(BoundingBox box)
 {
     return(box.Intersects(this));
 }
Esempio n. 4
0
 public static bool Intersects(BoundingSphere sphere, BoundingBox box)
 {
     return(BoundingBox.Intersects(box, sphere));
 }