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
min
Vector3The minimum extent of the BoundingBox.
max
Vector3The 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
box
BoundingBoxThe 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
box
BoundingBoxThe BoundingBox to test for overlap.
result
ContainmentTypeA 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
frustum
BoundingFrustumThe 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
sphere
BoundingSphereThe 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
sphere
BoundingSphereThe BoundingSphere to test for overlap.
result
ContainmentTypeA 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
point
or 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
point
Vector3The Vector3 to test.
result
ContainmentTypeContains if this BoundingBox contains
point
or 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
points
Vector3[]The array of Vector3 instances defining the point cloud to bound
index
intThe base index to start iterating from
count
intThe 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
points
IEnumerable<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
points
List<Vector3>The list of Vector3 instances defining the point cloud to bound
index
intThe base index to start iterating from
count
intThe 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
sphere
BoundingSphereThe 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
sphere
BoundingSphereThe BoundingSphere to enclose.
result
BoundingBoxA BoundingBox enclosing
sphere
.
CreateMerged(BoundingBox, BoundingBox)
Create the BoundingBox enclosing two other BoundingBox instances.
public static BoundingBox CreateMerged(BoundingBox original, BoundingBox additional)
Parameters
original
BoundingBoxA BoundingBox to enclose.
additional
BoundingBoxA BoundingBox to enclose.
Returns
- BoundingBox
The BoundingBox enclosing
original
andadditional
.
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
original
BoundingBoxA BoundingBox to enclose.
additional
BoundingBoxA BoundingBox to enclose.
result
BoundingBoxThe BoundingBox enclosing
original
andadditional
.
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
other
BoundingBoxThe 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
obj
objectThe 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
corners
Vector3[]The array to fill.
Exceptions
- ArgumentNullException
If
corners
is
.null
- ArgumentOutOfRangeException
If
corners
has 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
box
BoundingBoxThe BoundingBox to test for intersection.
Returns
- bool
if this BoundingBox intersectstrue
box
,
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
box
BoundingBoxThe BoundingBox to test for intersection.
result
bool
if this BoundingBox intersectstrue
box
,
if it does not.false
Intersects(BoundingFrustum)
Check if this BoundingBox intersects a BoundingFrustum.
public bool Intersects(BoundingFrustum frustum)
Parameters
frustum
BoundingFrustumThe BoundingFrustum to test for intersection.
Returns
- bool
if this BoundingBox intersectstrue
frustum
,
if it does not.false
Intersects(BoundingSphere)
Check if this BoundingBox intersects a BoundingFrustum.
public bool Intersects(BoundingSphere sphere)
Parameters
sphere
BoundingSphereThe BoundingFrustum to test for intersection.
Returns
- bool
if this BoundingBox intersectstrue
sphere
,
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
sphere
BoundingSphereThe BoundingFrustum to test for intersection.
result
bool
if this BoundingBox intersectstrue
sphere
,
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 intersectstrue
plane
,
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
plane
PlaneThe Plane to test for intersection.
result
PlaneIntersectionType
if this BoundingBox intersectstrue
plane
,
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
ray
RayThe Ray to test for intersection.
result
float?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
a
BoundingBoxA BoundingBox to compare the other.
b
BoundingBoxA 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
a
BoundingBoxA BoundingBox to compare the other.
b
BoundingBoxA BoundingBox to compare the other.
Returns
- bool
if a is not equal to this b,true
if it is.false