Table of Contents

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

min float3

Minimum point inside AABB.

max float3

Maximum point inside AABB.

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

float3

Extents

Computes the extents of the AABB.

public readonly float3 Extents { get; }

Property Value

float3

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

float3

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

bool

True if Min is componentwise less than or equal to Max.

Remarks

An AABB is considered valid if Min is componentwise less than or equal to Max.

Max

The maximum point contained by the AABB.

public float3 Max { readonly get; set; }

Property Value

float3

Remarks

If any component of Max is less than Min then this AABB is invalid.

See Also

Min

The minimum point contained by the AABB.

public float3 Min { readonly get; set; }

Property Value

float3

Remarks

If any component of Min is greater than Max then this AABB is invalid.

See Also

SurfaceArea

Computes the surface area for this axis aligned bounding box.

public readonly float SurfaceArea { get; }

Property Value

float

Zero

Creates a new AABB with zero extents, centered at the origin.

public static AABB Zero { get; }

Property Value

AABB

Methods

Contains(AABB)

Tests if the input AABB is contained entirely by this AABB.

public readonly bool Contains(AABB aabb)

Parameters

aabb AABB

AABB 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

point float3

Point 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

center float3

Center of AABB.

extents float3

Full extents of AABB.

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

center float3

Center of AABB.

halfExtents float3

Half extents of AABB.

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

aabb AABB

AABB 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

point float3

Point 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

other AABB

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and 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

signedDistance float

Signed 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

aabb AABB

AABB 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

left AABB
right AABB

Returns

bool

operator !=(AABB, AABB)

public static bool operator !=(AABB left, AABB right)

Parameters

left AABB
right AABB

Returns

bool