Struct BoundingBox
Represents an axis-aligned bounding box (AABB) in 3D space.
[DataContract]
public struct BoundingBox : IEquatable<BoundingBox>
- Implements
- Inherited Members
Constructors
BoundingBox(Vector3, Vector3)
Create a BoundingBox.
public BoundingBox(Vector3 min, Vector3 max)
Parameters
minVector3The minimum extent of the BoundingBox.
maxVector3The maximum extent of the BoundingBox.
Fields
CornerCount
The number of corners in a BoundingBox. This is equal to 8.
public const int CornerCount = 8
Field Value
Max
The maximum extent of this BoundingBox.
[DataMember]
public Vector3 Max
Field Value
Min
The minimum extent of this BoundingBox.
[DataMember]
public Vector3 Min
Field Value
Methods
Contains(BoundingBox)
Check if this BoundingBox contains another BoundingBox.
public ContainmentType Contains(BoundingBox box)
Parameters
boxBoundingBoxThe BoundingBox to test for overlap.
Returns
- ContainmentType
A value indicating if this BoundingBox contains, intersects with or is disjoint with
box.
Contains(ref BoundingBox, out ContainmentType)
Check if this BoundingBox contains another BoundingBox.
public void Contains(ref BoundingBox box, out ContainmentType result)
Parameters
boxBoundingBoxThe BoundingBox to test for overlap.
resultContainmentTypeA value indicating if this BoundingBox contains, intersects with or is disjoint with
box.
Contains(BoundingFrustum)
Check if this BoundingBox contains a BoundingFrustum.
public ContainmentType Contains(BoundingFrustum frustum)
Parameters
frustumBoundingFrustumThe BoundingFrustum to test for overlap.
Returns
- ContainmentType
A value indicating if this BoundingBox contains, intersects with or is disjoint with
frustum.
Contains(BoundingSphere)
Check if this BoundingBox contains a BoundingSphere.
public ContainmentType Contains(BoundingSphere sphere)
Parameters
sphereBoundingSphereThe BoundingSphere to test for overlap.
Returns
- ContainmentType
A value indicating if this BoundingBox contains, intersects with or is disjoint with
sphere.
Contains(ref BoundingSphere, out ContainmentType)
Check if this BoundingBox contains a BoundingSphere.
public void Contains(ref BoundingSphere sphere, out ContainmentType result)
Parameters
sphereBoundingSphereThe BoundingSphere to test for overlap.
resultContainmentTypeA value indicating if this BoundingBox contains, intersects with or is disjoint with
sphere.
Contains(Vector3)
Check if this BoundingBox contains a point.
public ContainmentType Contains(Vector3 point)
Parameters
Returns
- ContainmentType
Contains if this BoundingBox contains
pointor Disjoint if it does not.
Contains(ref Vector3, out ContainmentType)
Check if this BoundingBox contains a point.
public void Contains(ref Vector3 point, out ContainmentType result)
Parameters
pointVector3The Vector3 to test.
resultContainmentTypeContains if this BoundingBox contains
pointor Disjoint if it does not.
CreateFromPoints(Vector3[], int, int)
Create a bounding box from the given list of points.
public static BoundingBox CreateFromPoints(Vector3[] points, int index = 0, int count = -1)
Parameters
pointsVector3[]The array of Vector3 instances defining the point cloud to bound
indexintThe base index to start iterating from
countintThe number of points to iterate
Returns
- BoundingBox
A bounding box that encapsulates the given point cloud.
Exceptions
- ArgumentException
Thrown if the given array is null or has no points.
CreateFromPoints(IEnumerable<Vector3>)
Create the enclosing BoundingBox from the given list of points.
public static BoundingBox CreateFromPoints(IEnumerable<Vector3> points)
Parameters
pointsIEnumerable<Vector3>The list of Vector3 instances defining the point cloud to bound.
Returns
- BoundingBox
A BoundingBox that encloses the given point cloud.
Exceptions
- ArgumentException
Thrown if the given list has no points.
CreateFromPoints(List<Vector3>, int, int)
Create a bounding box from the given list of points.
public static BoundingBox CreateFromPoints(List<Vector3> points, int index = 0, int count = -1)
Parameters
pointsList<Vector3>The list of Vector3 instances defining the point cloud to bound
indexintThe base index to start iterating from
countintThe number of points to iterate
Returns
- BoundingBox
A bounding box that encapsulates the given point cloud.
Exceptions
- ArgumentException
Thrown if the given list is null or has no points.
CreateFromSphere(BoundingSphere)
Create the enclosing BoundingBox of a BoundingSphere.
public static BoundingBox CreateFromSphere(BoundingSphere sphere)
Parameters
sphereBoundingSphereThe BoundingSphere to enclose.
Returns
- BoundingBox
A BoundingBox enclosing
sphere.
CreateFromSphere(ref BoundingSphere, out BoundingBox)
Create the enclosing BoundingBox of a BoundingSphere.
public static void CreateFromSphere(ref BoundingSphere sphere, out BoundingBox result)
Parameters
sphereBoundingSphereThe BoundingSphere to enclose.
resultBoundingBoxA BoundingBox enclosing
sphere.
CreateMerged(BoundingBox, BoundingBox)
Create the BoundingBox enclosing two other BoundingBox instances.
public static BoundingBox CreateMerged(BoundingBox original, BoundingBox additional)
Parameters
originalBoundingBoxA BoundingBox to enclose.
additionalBoundingBoxA BoundingBox to enclose.
Returns
- BoundingBox
The BoundingBox enclosing
originalandadditional.
CreateMerged(ref BoundingBox, ref BoundingBox, out BoundingBox)
Create the BoundingBox enclosing two other BoundingBox instances.
public static void CreateMerged(ref BoundingBox original, ref BoundingBox additional, out BoundingBox result)
Parameters
originalBoundingBoxA BoundingBox to enclose.
additionalBoundingBoxA BoundingBox to enclose.
resultBoundingBoxThe BoundingBox enclosing
originalandadditional.
Deconstruct(out Vector3, out Vector3)
Deconstruction method for BoundingBox.
public void Deconstruct(out Vector3 min, out Vector3 max)
Parameters
Equals(BoundingBox)
Check if two BoundingBox instances are equal.
public bool Equals(BoundingBox other)
Parameters
otherBoundingBoxThe BoundingBox to compare with this BoundingBox.
Returns
- bool
if other is equal to this BoundingBox,true
if it is not.false
Equals(object)
Check if two BoundingBox instances are equal.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with this BoundingBox.
Returns
- bool
if obj is equal to this BoundingBox,true
if it is not.false
GetCorners()
Get an array of Vector3 containing the corners of this BoundingBox.
public Vector3[] GetCorners()
Returns
- Vector3[]
An array of Vector3 containing the corners of this BoundingBox.
GetCorners(Vector3[])
Fill the first 8 places of an array of Vector3 with the corners of this BoundingBox.
public void GetCorners(Vector3[] corners)
Parameters
cornersVector3[]The array to fill.
Exceptions
- ArgumentNullException
If
cornersis
.null- ArgumentOutOfRangeException
If
cornershas a length of less than 8.
GetHashCode()
Get the hash code for this BoundingBox.
public override int GetHashCode()
Returns
- int
A hash code for this BoundingBox.
Intersects(BoundingBox)
Check if this BoundingBox intersects another BoundingBox.
public bool Intersects(BoundingBox box)
Parameters
boxBoundingBoxThe BoundingBox to test for intersection.
Returns
- bool
if this BoundingBox intersectstruebox,
if it does not.false
Intersects(ref BoundingBox, out bool)
Check if this BoundingBox intersects another BoundingBox.
public void Intersects(ref BoundingBox box, out bool result)
Parameters
boxBoundingBoxThe BoundingBox to test for intersection.
resultbool
if this BoundingBox intersectstruebox,
if it does not.false
Intersects(BoundingFrustum)
Check if this BoundingBox intersects a BoundingFrustum.
public bool Intersects(BoundingFrustum frustum)
Parameters
frustumBoundingFrustumThe BoundingFrustum to test for intersection.
Returns
- bool
if this BoundingBox intersectstruefrustum,
if it does not.false
Intersects(BoundingSphere)
Check if this BoundingBox intersects a BoundingFrustum.
public bool Intersects(BoundingSphere sphere)
Parameters
sphereBoundingSphereThe BoundingFrustum to test for intersection.
Returns
- bool
if this BoundingBox intersectstruesphere,
if it does not.false
Intersects(ref BoundingSphere, out bool)
Check if this BoundingBox intersects a BoundingFrustum.
public void Intersects(ref BoundingSphere sphere, out bool result)
Parameters
sphereBoundingSphereThe BoundingFrustum to test for intersection.
resultbool
if this BoundingBox intersectstruesphere,
if it does not.false
Intersects(Plane)
Check if this BoundingBox intersects a Plane.
public PlaneIntersectionType Intersects(Plane plane)
Parameters
Returns
- PlaneIntersectionType
if this BoundingBox intersectstrueplane,
if it does not.false
Intersects(ref Plane, out PlaneIntersectionType)
Check if this BoundingBox intersects a Plane.
public void Intersects(ref Plane plane, out PlaneIntersectionType result)
Parameters
planePlaneThe Plane to test for intersection.
resultPlaneIntersectionType
if this BoundingBox intersectstrueplane,
if it does not.false
Intersects(Ray)
Check if this BoundingBox intersects a Ray.
public float? Intersects(Ray ray)
Parameters
Returns
- float?
The distance along the Ray to the intersection point or
if the Ray does not intesect this BoundingBox.null
Intersects(ref Ray, out float?)
Check if this BoundingBox intersects a Ray.
public void Intersects(ref Ray ray, out float? result)
Parameters
rayRayThe Ray to test for intersection.
resultfloat?The distance along the Ray to the intersection point or
if the Ray does not intesect this BoundingBox.null
ToString()
Get a string representation of this BoundingBox.
public override string ToString()
Returns
- string
A string representation of this BoundingBox.
Operators
operator ==(BoundingBox, BoundingBox)
Check if two BoundingBox instances are equal.
public static bool operator ==(BoundingBox a, BoundingBox b)
Parameters
aBoundingBoxA BoundingBox to compare the other.
bBoundingBoxA BoundingBox to compare the other.
Returns
- bool
if a is equal to this b,true
if it is not.false
operator !=(BoundingBox, BoundingBox)
Check if two BoundingBox instances are not equal.
public static bool operator !=(BoundingBox a, BoundingBox b)
Parameters
aBoundingBoxA BoundingBox to compare the other.
bBoundingBoxA BoundingBox to compare the other.
Returns
- bool
if a is not equal to this b,true
if it is.false