Show / Hide Table of Contents

Class BoundingBox

Defines an axis-aligned box-shaped 3D volume.

Inheritance
System.Object
BoundingBox
Namespace: VRageMath
Assembly: VRage.Math.dll
Syntax
public sealed class BoundingBox : ValueType, IEquatable<BoundingBox>

Constructors

BoundingBox(BoundingBoxD)

Creates an instance of BoundingBox from BoundingBoxD (helper for transformed BBs)

Declaration
public BoundingBox(BoundingBoxD bbd)
Parameters
Type Name Description
BoundingBoxD bbd

BoundingBox(BoundingBoxI)

Creates an instance of BoundingBox from BoundingBoxI

Declaration
public BoundingBox(BoundingBoxI bbd)
Parameters
Type Name Description
BoundingBoxI bbd

BoundingBox(Vector3, Vector3)

Creates an instance of BoundingBox.

Declaration
public BoundingBox(Vector3 min, Vector3 max)
Parameters
Type Name Description
Vector3 min

The minimum point the BoundingBox includes.

Vector3 max

The maximum point the BoundingBox includes.

Fields

Comparer

Declaration
public static readonly BoundingBox.ComparerType Comparer
Field Value
Type Description
BoundingBox.ComparerType

CornerCount

Specifies the total number of corners (8) in the BoundingBox.

Declaration
public const int CornerCount = 8
Field Value
Type Description
System.Int32

Invalid

Declaration
public static readonly BoundingBox Invalid
Field Value
Type Description
BoundingBox

Max

The maximum point the BoundingBox contains.

Declaration
public Vector3 Max
Field Value
Type Description
Vector3

Min

The minimum point the BoundingBox contains.

Declaration
public Vector3 Min
Field Value
Type Description
Vector3

Properties

Center

Calculates center

Declaration
public Vector3 Center { get; }
Property Value
Type Description
Vector3

Corners

Declaration
public BoxCornerEnumerator Corners { get; set; }
Property Value
Type Description
BoxCornerEnumerator

Depth

Declaration
public float Depth { get; }
Property Value
Type Description
System.Single

Extents

Declaration
public Vector3 Extents { get; }
Property Value
Type Description
Vector3

HalfExtents

Declaration
public Vector3 HalfExtents { get; }
Property Value
Type Description
Vector3

Height

Declaration
public float Height { get; }
Property Value
Type Description
System.Single

Matrix

Matrix of AABB, respecting center and size

Declaration
public Matrix Matrix { get; }
Property Value
Type Description
Matrix

Perimeter

return perimeter of edges

Declaration
public float Perimeter { get; }
Property Value
Type Description
System.Single

Size

Size

Declaration
public Vector3 Size { get; }
Property Value
Type Description
Vector3

Width

Declaration
public float Width { get; }
Property Value
Type Description
System.Single

Methods

Contains(BoundingBox)

Tests whether the BoundingBox contains another BoundingBox.

Declaration
public ContainmentType Contains(BoundingBox box)
Parameters
Type Name Description
BoundingBox box

The BoundingBox to test for overlap.

Returns
Type Description
ContainmentType

Contains(ref BoundingBox, out ContainmentType)

Tests whether the BoundingBox contains a BoundingBox.

Declaration
public void Contains(ref BoundingBox box, out ContainmentType result)
Parameters
Type Name Description
BoundingBox box

The BoundingBox to test for overlap.

ContainmentType result

[OutAttribute] Enumeration indicating the extent of overlap.

Contains(BoundingFrustum)

Tests whether the BoundingBox contains a BoundingFrustum.

Declaration
public ContainmentType Contains(BoundingFrustum frustum)
Parameters
Type Name Description
BoundingFrustum frustum

The BoundingFrustum to test for overlap.

Returns
Type Description
ContainmentType

Contains(BoundingSphere)

Tests whether the BoundingBox contains a BoundingSphere.

Declaration
public ContainmentType Contains(BoundingSphere sphere)
Parameters
Type Name Description
BoundingSphere sphere

The BoundingSphere to test for overlap.

Returns
Type Description
ContainmentType

Contains(ref BoundingSphere, out ContainmentType)

Tests whether the BoundingBox contains a BoundingSphere.

Declaration
public void Contains(ref BoundingSphere sphere, out ContainmentType result)
Parameters
Type Name Description
BoundingSphere sphere

The BoundingSphere to test for overlap.

ContainmentType result

[OutAttribute] Enumeration indicating the extent of overlap.

Contains(Vector3)

Tests whether the BoundingBox contains a point.

Declaration
public ContainmentType Contains(Vector3 point)
Parameters
Type Name Description
Vector3 point

The point to test for overlap.

Returns
Type Description
ContainmentType

Contains(ref Vector3, out ContainmentType)

Tests whether the BoundingBox contains a point.

Declaration
public void Contains(ref Vector3 point, out ContainmentType result)
Parameters
Type Name Description
Vector3 point

The point to test for overlap.

ContainmentType result

[OutAttribute] Enumeration indicating the extent of overlap.

Contains(Vector3D)

Declaration
public ContainmentType Contains(Vector3D point)
Parameters
Type Name Description
Vector3D point
Returns
Type Description
ContainmentType

CreateFromHalfExtent(Vector3, Single)

Declaration
public static BoundingBox CreateFromHalfExtent(Vector3 center, float halfExtent)
Parameters
Type Name Description
Vector3 center
System.Single halfExtent
Returns
Type Description
BoundingBox

CreateFromHalfExtent(Vector3, Vector3)

Declaration
public static BoundingBox CreateFromHalfExtent(Vector3 center, Vector3 halfExtent)
Parameters
Type Name Description
Vector3 center
Vector3 halfExtent
Returns
Type Description
BoundingBox

CreateFromPoints(IEnumerable<Vector3>)

Creates the smallest BoundingBox that will contain a group of points.

Declaration
public static BoundingBox CreateFromPoints(IEnumerable<Vector3> points)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<Vector3> points

A list of points the BoundingBox should contain.

Returns
Type Description
BoundingBox

CreateFromSphere(BoundingSphere)

Creates the smallest BoundingBox that will contain the specified BoundingSphere.

Declaration
public static BoundingBox CreateFromSphere(BoundingSphere sphere)
Parameters
Type Name Description
BoundingSphere sphere

The BoundingSphere to contain.

Returns
Type Description
BoundingBox

CreateFromSphere(ref BoundingSphere, out BoundingBox)

Creates the smallest BoundingBox that will contain the specified BoundingSphere.

Declaration
public static void CreateFromSphere(ref BoundingSphere sphere, out BoundingBox result)
Parameters
Type Name Description
BoundingSphere sphere

The BoundingSphere to contain.

BoundingBox result

[OutAttribute] The created BoundingBox.

CreateInvalid()

Declaration
public static BoundingBox CreateInvalid()
Returns
Type Description
BoundingBox

CreateMerged(BoundingBox, BoundingBox)

Creates the smallest BoundingBox that contains the two specified BoundingBox instances.

Declaration
public static BoundingBox CreateMerged(BoundingBox original, BoundingBox additional)
Parameters
Type Name Description
BoundingBox original

One of the BoundingBoxs to contain.

BoundingBox additional

One of the BoundingBoxs to contain.

Returns
Type Description
BoundingBox

CreateMerged(ref BoundingBox, ref BoundingBox, out BoundingBox)

Creates the smallest BoundingBox that contains the two specified BoundingBox instances.

Declaration
public static void CreateMerged(ref BoundingBox original, ref BoundingBox additional, out BoundingBox result)
Parameters
Type Name Description
BoundingBox original

One of the BoundingBox instances to contain.

BoundingBox additional

One of the BoundingBox instances to contain.

BoundingBox result

[OutAttribute] The created BoundingBox.

Distance(Vector3)

Declaration
public float Distance(Vector3 point)
Parameters
Type Name Description
Vector3 point
Returns
Type Description
System.Single

DistanceSquared(Vector3)

Declaration
public float DistanceSquared(Vector3 point)
Parameters
Type Name Description
Vector3 point
Returns
Type Description
System.Single

Equals(Object)

Determines whether two instances of BoundingBox are equal.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

The Object to compare with the current BoundingBox.

Returns
Type Description
System.Boolean

Equals(BoundingBox)

Determines whether two instances of BoundingBox are equal.

Declaration
public bool Equals(BoundingBox other)
Parameters
Type Name Description
BoundingBox other

The BoundingBox to compare with the current BoundingBox.

Returns
Type Description
System.Boolean

Equals(BoundingBox, Single)

Declaration
public bool Equals(BoundingBox other, float epsilon)
Parameters
Type Name Description
BoundingBox other
System.Single epsilon
Returns
Type Description
System.Boolean

GetCorners()

Gets an array of points that make up the corners of the BoundingBox. ALLOCATION!

Declaration
public Vector3[] GetCorners()
Returns
Type Description
Vector3[]

GetCorners(Vector3[])

Gets the array of points that make up the corners of the BoundingBox.

Declaration
public void GetCorners(Vector3[] corners)
Parameters
Type Name Description
Vector3[] corners

An existing array of at least 8 Vector3 points where the corners of the BoundingBox are written.

GetCornersUnsafe(Vector3*)

Gets the array of points that make up the corners of the BoundingBox.

Declaration
public void GetCornersUnsafe(Vector3*corners)
Parameters
Type Name Description
Vector3* corners

An existing array of at least 8 Vector3 points where the corners of the BoundingBox are written.

GetHashCode()

Gets the hash code for this instance.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

GetIncluded(Vector3)

Declaration
public BoundingBox GetIncluded(Vector3 point)
Parameters
Type Name Description
Vector3 point
Returns
Type Description
BoundingBox

Include(BoundingBox)

Declaration
public BoundingBox Include(BoundingBox box)
Parameters
Type Name Description
BoundingBox box
Returns
Type Description
BoundingBox

Include(ref BoundingBox)

return expanded aabb (aabb include aabb)

Declaration
public BoundingBox Include(ref BoundingBox box)
Parameters
Type Name Description
BoundingBox box
Returns
Type Description
BoundingBox

Include(ref BoundingFrustum)

Declaration
public BoundingBox Include(ref BoundingFrustum frustum)
Parameters
Type Name Description
BoundingFrustum frustum
Returns
Type Description
BoundingBox

Include(BoundingSphere)

Declaration
public BoundingBox Include(BoundingSphere sphere)
Parameters
Type Name Description
BoundingSphere sphere
Returns
Type Description
BoundingBox

Include(ref BoundingSphere)

Declaration
public BoundingBox Include(ref BoundingSphere sphere)
Parameters
Type Name Description
BoundingSphere sphere
Returns
Type Description
BoundingBox

Include(ref Line)

Declaration
public void Include(ref Line line)
Parameters
Type Name Description
Line line

Include(Vector3)

Declaration
public BoundingBox Include(Vector3 point)
Parameters
Type Name Description
Vector3 point
Returns
Type Description
BoundingBox

Include(Vector3, Vector3, Vector3)

Declaration
public BoundingBox Include(Vector3 p0, Vector3 p1, Vector3 p2)
Parameters
Type Name Description
Vector3 p0
Vector3 p1
Vector3 p2
Returns
Type Description
BoundingBox

Include(ref Vector3)

return expanded aabb (aabb include point)

Declaration
public BoundingBox Include(ref Vector3 point)
Parameters
Type Name Description
Vector3 point
Returns
Type Description
BoundingBox

Include(ref Vector3, ref Vector3, ref Vector3)

Declaration
public BoundingBox Include(ref Vector3 p0, ref Vector3 p1, ref Vector3 p2)
Parameters
Type Name Description
Vector3 p0
Vector3 p1
Vector3 p2
Returns
Type Description
BoundingBox

Inflate(Single)

Declaration
public void Inflate(float size)
Parameters
Type Name Description
System.Single size

Inflate(Vector3)

Declaration
public void Inflate(Vector3 size)
Parameters
Type Name Description
Vector3 size

InflateToMinimum(Vector3)

Declaration
public void InflateToMinimum(Vector3 minimumSize)
Parameters
Type Name Description
Vector3 minimumSize

Intersect(BoundingBox)

Returns bounding box which is intersection of this and box
Result is invalid box when there's no intersection (Min > Max)

Declaration
public BoundingBox Intersect(BoundingBox box)
Parameters
Type Name Description
BoundingBox box
Returns
Type Description
BoundingBox

Intersects(BoundingBox)

Checks whether the current BoundingBox intersects another BoundingBox.

Declaration
public bool Intersects(BoundingBox box)
Parameters
Type Name Description
BoundingBox box

The BoundingBox to check for intersection with.

Returns
Type Description
System.Boolean

Intersects(ref BoundingBox)

Declaration
public bool Intersects(ref BoundingBox box)
Parameters
Type Name Description
BoundingBox box
Returns
Type Description
System.Boolean

Intersects(ref BoundingBox, out Boolean)

Checks whether the current BoundingBox intersects another BoundingBox.

Declaration
public void Intersects(ref BoundingBox box, out bool result)
Parameters
Type Name Description
BoundingBox box

The BoundingBox to check for intersection with.

System.Boolean result

[OutAttribute] true if the BoundingBox instances intersect; false otherwise.

Intersects(BoundingFrustum)

Checks whether the current BoundingBox intersects a BoundingFrustum.

Declaration
public bool Intersects(BoundingFrustum frustum)
Parameters
Type Name Description
BoundingFrustum frustum

The BoundingFrustum to check for intersection with.

Returns
Type Description
System.Boolean

Intersects(BoundingSphere)

Checks whether the current BoundingBox intersects a BoundingSphere.

Declaration
public bool Intersects(BoundingSphere sphere)
Parameters
Type Name Description
BoundingSphere sphere

The BoundingSphere to check for intersection with.

Returns
Type Description
System.Boolean

Intersects(ref BoundingSphere)

Declaration
public bool Intersects(ref BoundingSphere sphere)
Parameters
Type Name Description
BoundingSphere sphere
Returns
Type Description
System.Boolean

Intersects(ref BoundingSphere, out Boolean)

Checks whether the current BoundingBox intersects a BoundingSphere.

Declaration
public void Intersects(ref BoundingSphere sphere, out bool result)
Parameters
Type Name Description
BoundingSphere sphere

The BoundingSphere to check for intersection with.

System.Boolean result

[OutAttribute] true if the BoundingBox and BoundingSphere intersect; false otherwise.

Intersects(ref BoundingSphereD)

Declaration
public bool Intersects(ref BoundingSphereD sphere)
Parameters
Type Name Description
BoundingSphereD sphere
Returns
Type Description
System.Boolean

Intersects(Line, out Single)

Declaration
public bool Intersects(Line line, out float distance)
Parameters
Type Name Description
Line line
System.Single distance
Returns
Type Description
System.Boolean

Intersects(Plane)

Checks whether the current BoundingBox intersects a Plane.

Declaration
public PlaneIntersectionType Intersects(Plane plane)
Parameters
Type Name Description
Plane plane

The Plane to check for intersection with.

Returns
Type Description
PlaneIntersectionType

Intersects(ref Plane, out PlaneIntersectionType)

Checks whether the current BoundingBox intersects a Plane.

Declaration
public void Intersects(ref Plane plane, out PlaneIntersectionType result)
Parameters
Type Name Description
Plane plane

The Plane to check for intersection with.

PlaneIntersectionType result

[OutAttribute] An enumeration indicating whether the BoundingBox intersects the Plane.

Intersects(Ray)

Checks whether the current BoundingBox intersects a Ray.

Declaration
public Nullable<float> Intersects(Ray ray)
Parameters
Type Name Description
Ray ray

The Ray to check for intersection with.

Returns
Type Description
System.Nullable<System.Single>

Intersects(ref Ray, out Nullable<Single>)

Checks whether the current BoundingBox intersects a Ray.

Declaration
public void Intersects(ref Ray ray, out Nullable<float> result)
Parameters
Type Name Description
Ray ray

The Ray to check for intersection with.

System.Nullable<System.Single> result

[OutAttribute] Distance at which the ray intersects the BoundingBox, or null if there is no intersection.

IntersectsTriangle(Vector3, Vector3, Vector3)

Declaration
public bool IntersectsTriangle(Vector3 v0, Vector3 v1, Vector3 v2)
Parameters
Type Name Description
Vector3 v0
Vector3 v1
Vector3 v2
Returns
Type Description
System.Boolean

IntersectsTriangle(ref Vector3, ref Vector3, ref Vector3)

Declaration
public bool IntersectsTriangle(ref Vector3 v0, ref Vector3 v1, ref Vector3 v2)
Parameters
Type Name Description
Vector3 v0
Vector3 v1
Vector3 v2
Returns
Type Description
System.Boolean

IsBetween(Single, Single, Single)

Declaration
public static bool IsBetween(float number, float min, float max)
Parameters
Type Name Description
System.Single number
System.Single min
System.Single max
Returns
Type Description
System.Boolean

ProjectedArea(Vector3)

Declaration
public float ProjectedArea(Vector3 viewDir)
Parameters
Type Name Description
Vector3 viewDir
Returns
Type Description
System.Single

Round()

Declaration
public BoundingBoxI Round()
Returns
Type Description
BoundingBoxI

Round(Int32)

Declaration
public BoundingBox Round(int decimals)
Parameters
Type Name Description
System.Int32 decimals
Returns
Type Description
BoundingBox

Scale(Vector3)

Declaration
public void Scale(Vector3 scale)
Parameters
Type Name Description
Vector3 scale

SurfaceArea()

Declaration
public float SurfaceArea()
Returns
Type Description
System.Single

ToString()

Returns a String that represents the current BoundingBox.

Declaration
public override string ToString()
Returns
Type Description
System.String

Transform(Matrix)

Declaration
public BoundingBox Transform(Matrix worldMatrix)
Parameters
Type Name Description
Matrix worldMatrix
Returns
Type Description
BoundingBox

Transform(ref Matrix)

Declaration
public BoundingBox Transform(ref Matrix m)
Parameters
Type Name Description
Matrix m
Returns
Type Description
BoundingBox

Transform(ref Matrix, ref BoundingBox)

Declaration
public void Transform(ref Matrix m, ref BoundingBox bb)
Parameters
Type Name Description
Matrix m
BoundingBox bb

Transform(MatrixD)

Declaration
public BoundingBoxD Transform(MatrixD worldMatrix)
Parameters
Type Name Description
MatrixD worldMatrix
Returns
Type Description
BoundingBoxD

Transform(ref MatrixD)

Declaration
public BoundingBoxD Transform(ref MatrixD m)
Parameters
Type Name Description
MatrixD m
Returns
Type Description
BoundingBoxD

Transform(ref MatrixD, ref BoundingBoxD)

Declaration
public void Transform(ref MatrixD m, ref BoundingBoxD bb)
Parameters
Type Name Description
MatrixD m
BoundingBoxD bb

Translate(Matrix)

Translate

Declaration
public BoundingBox Translate(Matrix worldMatrix)
Parameters
Type Name Description
Matrix worldMatrix
Returns
Type Description
BoundingBox

Translate(Vector3)

Translate

Declaration
public BoundingBox Translate(Vector3 vctTranlsation)
Parameters
Type Name Description
Vector3 vctTranlsation
Returns
Type Description
BoundingBox

Volume()

Declaration
public float Volume()
Returns
Type Description
System.Single

Operators

Equality(BoundingBox, BoundingBox)

Determines whether two instances of BoundingBox are equal.

Declaration
public static bool operator ==(BoundingBox a, BoundingBox b)
Parameters
Type Name Description
BoundingBox a

BoundingBox to compare.

BoundingBox b

BoundingBox to compare.

Returns
Type Description
System.Boolean

Inequality(BoundingBox, BoundingBox)

Determines whether two instances of BoundingBox are not equal.

Declaration
public static bool operator !=(BoundingBox a, BoundingBox b)
Parameters
Type Name Description
BoundingBox a

The object to the left of the inequality operator.

BoundingBox b

The object to the right of the inequality operator.

Returns
Type Description
System.Boolean
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾