Struct AABB
- Namespace
- Misaki.HighPerformance.Mathematics.Geometry
- Assembly
- Misaki.HighPerformance.Mathematics.dll
Represents an axis-aligned bounding box (AABB) defined by minimum and maximum points in 3D space.
public struct AABB : IEquatable<AABB>
- Implements
- Inherited Members
Constructors
AABB(float3, float3)
Constructs the AABB with the given minimum and maximum.
public AABB(float3 min, float3 max)
Parameters
Remarks
If you have a center and extents, you can call CreateFromCenterAndExtents(float3, float3) or CreateFromCenterAndHalfExtents(float3, float3) to create the AABB.
Properties
Center
Computes the center of the AABB.
public readonly float3 Center { get; }
Property Value
Extents
Computes the extents of the AABB.
public readonly float3 Extents { get; }
Property Value
Remarks
Extents is the componentwise distance between min and max.
HalfExtents
Computes the half extents of the AABB.
public readonly float3 HalfExtents { get; }
Property Value
Remarks
HalfExtents is half of the componentwise distance between min and max. Subtracting HalfExtents from Center gives Min and adding HalfExtents to Center gives Max.
IsValid
Check if the AABB is valid.
public readonly bool IsValid { get; }
Property Value
Remarks
Max
The maximum point contained by the AABB.
public float3 Max { readonly get; set; }
Property Value
Remarks
- See Also
Min
The minimum point contained by the AABB.
public float3 Min { readonly get; set; }
Property Value
Remarks
- See Also
SurfaceArea
Computes the surface area for this axis aligned bounding box.
public readonly float SurfaceArea { get; }
Property Value
Zero
Creates a new AABB with zero extents, centered at the origin.
public static AABB Zero { get; }
Property Value
Methods
Contains(AABB)
Tests if the input AABB is contained entirely by this AABB.
public readonly bool Contains(AABB aabb)
Parameters
aabbAABBAABB to test.
Returns
- bool
True if input AABB is contained entirely by this AABB.
Contains(float3)
Tests if the input point is contained by the AABB.
public readonly bool Contains(float3 point)
Parameters
pointfloat3Point to test.
Returns
- bool
True if AABB contains the input point.
CreateFromCenterAndExtents(float3, float3)
Creates the AABB from a center and extents.
public static AABB CreateFromCenterAndExtents(float3 center, float3 extents)
Parameters
Returns
- AABB
AABB created from inputs.
Remarks
This function takes full extents. It is the distance between Min and Max. If you have half extents, you can call CreateFromCenterAndHalfExtents(float3, float3).
CreateFromCenterAndHalfExtents(float3, float3)
Creates the AABB from a center and half extents.
public static AABB CreateFromCenterAndHalfExtents(float3 center, float3 halfExtents)
Parameters
Returns
- AABB
AABB created from inputs.
Remarks
This function takes half extents. It is half the distance between Min and Max. If you have full extents, you can call CreateFromCenterAndExtents(float3, float3).
Encapsulate(AABB)
Encapsulates the given AABB.
public void Encapsulate(AABB aabb)
Parameters
aabbAABBAABB to encapsulate.
Remarks
Modifies this AABB so that it contains the given AABB. If the given AABB is already contained by this AABB, then this AABB doesn't change.
- See Also
Encapsulate(float3)
Encapsulate the given point.
public void Encapsulate(float3 point)
Parameters
pointfloat3Point to encapsulate.
Remarks
Modifies this AABB so that it contains the given point. If the given point is already contained by this AABB, then this AABB doesn't change.
- See Also
Equals(AABB)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(AABB other)
Parameters
otherAABBAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
Expand(float)
Expands the AABB by the given signed distance.
public void Expand(float signedDistance)
Parameters
signedDistancefloatSigned distance to expand the AABB with.
Remarks
Positive distance expands the AABB while negative distance shrinks the AABB.
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Overlaps(AABB)
Tests if the input AABB overlaps this AABB.
public readonly bool Overlaps(AABB aabb)
Parameters
aabbAABBAABB to test.
Returns
- bool
True if input AABB overlaps with this AABB.
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(AABB, AABB)
public static bool operator ==(AABB left, AABB right)
Parameters
Returns
operator !=(AABB, AABB)
public static bool operator !=(AABB left, AABB right)