Table of Contents

Struct BoundingSphere

Namespace
Microsoft.Xna.Framework
Assembly
MonoGame.Framework.dll

Describes a sphere in 3D-space for bounding operations.

[DataContract]
public struct BoundingSphere : IEquatable<BoundingSphere>
Implements
Inherited Members

Constructors

BoundingSphere(Vector3, float)

Constructs a bounding sphere with the specified center and radius.

public BoundingSphere(Vector3 center, float radius)

Parameters

center Vector3

The sphere center.

radius float

The sphere radius.

Fields

Center

The sphere center.

[DataMember]
public Vector3 Center

Field Value

Vector3

Radius

The sphere radius.

[DataMember]
public float Radius

Field Value

float

Methods

Contains(BoundingBox)

Test if a bounding box is fully inside, outside, or just intersecting the sphere.

public ContainmentType Contains(BoundingBox box)

Parameters

box BoundingBox

The box for testing.

Returns

ContainmentType

The containment type.

Contains(ref BoundingBox, out ContainmentType)

Test if a bounding box is fully inside, outside, or just intersecting the sphere.

public void Contains(ref BoundingBox box, out ContainmentType result)

Parameters

box BoundingBox

The box for testing.

result ContainmentType

The containment type as an output parameter.

Contains(BoundingFrustum)

Test if a frustum is fully inside, outside, or just intersecting the sphere.

public ContainmentType Contains(BoundingFrustum frustum)

Parameters

frustum BoundingFrustum

The frustum for testing.

Returns

ContainmentType

The containment type.

Contains(ref BoundingFrustum, out ContainmentType)

Test if a frustum is fully inside, outside, or just intersecting the sphere.

public void Contains(ref BoundingFrustum frustum, out ContainmentType result)

Parameters

frustum BoundingFrustum

The frustum for testing.

result ContainmentType

The containment type as an output parameter.

Contains(BoundingSphere)

Test if a sphere is fully inside, outside, or just intersecting the sphere.

public ContainmentType Contains(BoundingSphere sphere)

Parameters

sphere BoundingSphere

The other sphere for testing.

Returns

ContainmentType

The containment type.

Contains(ref BoundingSphere, out ContainmentType)

Test if a sphere is fully inside, outside, or just intersecting the sphere.

public void Contains(ref BoundingSphere sphere, out ContainmentType result)

Parameters

sphere BoundingSphere

The other sphere for testing.

result ContainmentType

The containment type as an output parameter.

Contains(Vector3)

Test if a point is fully inside, outside, or just intersecting the sphere.

public ContainmentType Contains(Vector3 point)

Parameters

point Vector3

The vector in 3D-space for testing.

Returns

ContainmentType

The containment type.

Contains(ref Vector3, out ContainmentType)

Test if a point is fully inside, outside, or just intersecting the sphere.

public void Contains(ref Vector3 point, out ContainmentType result)

Parameters

point Vector3

The vector in 3D-space for testing.

result ContainmentType

The containment type as an output parameter.

CreateFromBoundingBox(BoundingBox)

Creates the smallest BoundingSphere that can contain a specified BoundingBox.

public static BoundingSphere CreateFromBoundingBox(BoundingBox box)

Parameters

box BoundingBox

The box to create the sphere from.

Returns

BoundingSphere

The new BoundingSphere.

CreateFromBoundingBox(ref BoundingBox, out BoundingSphere)

Creates the smallest BoundingSphere that can contain a specified BoundingBox.

public static void CreateFromBoundingBox(ref BoundingBox box, out BoundingSphere result)

Parameters

box BoundingBox

The box to create the sphere from.

result BoundingSphere

The new BoundingSphere as an output parameter.

CreateFromFrustum(BoundingFrustum)

Creates the smallest BoundingSphere that can contain a specified BoundingFrustum.

public static BoundingSphere CreateFromFrustum(BoundingFrustum frustum)

Parameters

frustum BoundingFrustum

The frustum to create the sphere from.

Returns

BoundingSphere

The new BoundingSphere.

CreateFromPoints(IEnumerable<Vector3>)

Creates the smallest BoundingSphere that can contain a specified list of points in 3D-space.

public static BoundingSphere CreateFromPoints(IEnumerable<Vector3> points)

Parameters

points IEnumerable<Vector3>

List of point to create the sphere from.

Returns

BoundingSphere

The new BoundingSphere.

CreateMerged(BoundingSphere, BoundingSphere)

Creates the smallest BoundingSphere that can contain two spheres.

public static BoundingSphere CreateMerged(BoundingSphere original, BoundingSphere additional)

Parameters

original BoundingSphere

First sphere.

additional BoundingSphere

Second sphere.

Returns

BoundingSphere

The new BoundingSphere.

CreateMerged(ref BoundingSphere, ref BoundingSphere, out BoundingSphere)

Creates the smallest BoundingSphere that can contain two spheres.

public static void CreateMerged(ref BoundingSphere original, ref BoundingSphere additional, out BoundingSphere result)

Parameters

original BoundingSphere

First sphere.

additional BoundingSphere

Second sphere.

result BoundingSphere

The new BoundingSphere as an output parameter.

Deconstruct(out Vector3, out float)

Deconstruction method for BoundingSphere.

public void Deconstruct(out Vector3 center, out float radius)

Parameters

center Vector3
radius float

Equals(BoundingSphere)

Compares whether current instance is equal to specified BoundingSphere.

public bool Equals(BoundingSphere other)

Parameters

other BoundingSphere

The BoundingSphere to compare.

Returns

bool

true if the instances are equal; false otherwise.

Equals(object)

Compares whether current instance is equal to specified object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare.

Returns

bool

true if the instances are equal; false otherwise.

GetHashCode()

Gets the hash code of this BoundingSphere.

public override int GetHashCode()

Returns

int

Hash code of this BoundingSphere.

Intersects(BoundingBox)

Gets whether or not a specified BoundingBox intersects with this sphere.

public bool Intersects(BoundingBox box)

Parameters

box BoundingBox

The box for testing.

Returns

bool

true if BoundingBox intersects with this sphere; false otherwise.

Intersects(ref BoundingBox, out bool)

Gets whether or not a specified BoundingBox intersects with this sphere.

public void Intersects(ref BoundingBox box, out bool result)

Parameters

box BoundingBox

The box for testing.

result bool

true if BoundingBox intersects with this sphere; false otherwise. As an output parameter.

Intersects(BoundingSphere)

Gets whether or not the other BoundingSphere intersects with this sphere.

public bool Intersects(BoundingSphere sphere)

Parameters

sphere BoundingSphere

The other sphere for testing.

Returns

bool

true if other BoundingSphere intersects with this sphere; false otherwise.

Intersects(ref BoundingSphere, out bool)

Gets whether or not the other BoundingSphere intersects with this sphere.

public void Intersects(ref BoundingSphere sphere, out bool result)

Parameters

sphere BoundingSphere

The other sphere for testing.

result bool

true if other BoundingSphere intersects with this sphere; false otherwise. As an output parameter.

Intersects(Plane)

Gets whether or not a specified Plane intersects with this sphere.

public PlaneIntersectionType Intersects(Plane plane)

Parameters

plane Plane

The plane for testing.

Returns

PlaneIntersectionType

Type of intersection.

Intersects(ref Plane, out PlaneIntersectionType)

Gets whether or not a specified Plane intersects with this sphere.

public void Intersects(ref Plane plane, out PlaneIntersectionType result)

Parameters

plane Plane

The plane for testing.

result PlaneIntersectionType

Type of intersection as an output parameter.

Intersects(Ray)

Gets whether or not a specified Ray intersects with this sphere.

public float? Intersects(Ray ray)

Parameters

ray Ray

The ray for testing.

Returns

float?

Distance of ray intersection or null if there is no intersection.

Intersects(ref Ray, out float?)

Gets whether or not a specified Ray intersects with this sphere.

public void Intersects(ref Ray ray, out float? result)

Parameters

ray Ray

The ray for testing.

result float?

Distance of ray intersection or null if there is no intersection as an output parameter.

ToString()

Returns a string representation of this BoundingSphere in the format: {Center:[Center] Radius:[Radius]}

public override string ToString()

Returns

string

A string representation of this BoundingSphere.

Transform(Matrix)

Creates a new BoundingSphere that contains a transformation of translation and scale from this sphere by the specified Matrix.

public BoundingSphere Transform(Matrix matrix)

Parameters

matrix Matrix

The transformation Matrix.

Returns

BoundingSphere

Transformed BoundingSphere.

Transform(ref Matrix, out BoundingSphere)

Creates a new BoundingSphere that contains a transformation of translation and scale from this sphere by the specified Matrix.

public void Transform(ref Matrix matrix, out BoundingSphere result)

Parameters

matrix Matrix

The transformation Matrix.

result BoundingSphere

Transformed BoundingSphere as an output parameter.

Operators

operator ==(BoundingSphere, BoundingSphere)

Compares whether two BoundingSphere instances are equal.

public static bool operator ==(BoundingSphere a, BoundingSphere b)

Parameters

a BoundingSphere

BoundingSphere instance on the left of the equal sign.

b BoundingSphere

BoundingSphere instance on the right of the equal sign.

Returns

bool

true if the instances are equal; false otherwise.

operator !=(BoundingSphere, BoundingSphere)

Compares whether two BoundingSphere instances are not equal.

public static bool operator !=(BoundingSphere a, BoundingSphere b)

Parameters

a BoundingSphere

BoundingSphere instance on the left of the not equal sign.

b BoundingSphere

BoundingSphere instance on the right of the not equal sign.

Returns

bool

true if the instances are not equal; false otherwise.