Engines/FlatRedBallXNA/FlatRedBall/Math/Geometry/Sphere.cs
/// <summary>
/// Returns whether this instance overlaps the argument AxisAlignedCube
/// </summary>
/// <param name="cube">The instance AxisAlignedCube to test against.</param>
/// <returns>Whether collision has occurred</returns>
Returns whether this instance overlaps the argument AxisAlignedCube
Returns whether this instance overlaps the argument AxisAlignedCube
public bool CollideAgainst(AxisAlignedCube cube)
        {
            UpdateDependencies(TimeManager.CurrentTime);
            cube.UpdateDependencies(TimeManager.CurrentTime);
            Vector3 relativeCenter = Position - cube.Position;
            if (System.Math.Abs(relativeCenter.X) - Radius > cube.ScaleX ||
                System.Math.Abs(relativeCenter.Y) - Radius > cube.ScaleY ||
                System.Math.Abs(relativeCenter.Z) - Radius > cube.ScaleZ)
            {
                return false;
            }
            Vector3 nearest = GetNearestPoint(cube, relativeCenter);
            float distance = (nearest - relativeCenter).LengthSquared();
            return (distance <= Radius * Radius);
        }
public bool CollideAgainst ( AxisAlignedCube cube ) { UpdateDependencies ( TimeManager . CurrentTime ) ; cube . UpdateDependencies ( TimeManager . CurrentTime ) ; Vector3 relativeCenter = Position - cube . Position ; if ( System . Math . Abs ( relativeCenter . X ) - Radius > cube . ScaleX || System . Math . Abs ( relativeCenter . Y ) - Radius > cube . ScaleY || System . Math . Abs ( relativeCenter . Z ) - Radius > cube . ScaleZ ) { return false ; } Vector3 nearest = GetNearestPoint ( cube , relativeCenter ) ; float distance = ( nearest - relativeCenter ) . LengthSquared ( ) ; return ( distance <= Radius * Radius ) ; }
Returns whether this instance overlaps the argument AxisAlignedCube
Returns whether this instance overlaps the argument AxisAlignedCube
Whether collision has occurred
Whether collision has occurred
cube
AxisAlignedCube
The instance AxisAlignedCube to test against.
The instance AxisAlignedCube to test against .