Show / Hide Table of Contents

Struct Box3

Defines an axis-aligned 3d box (rectangular prism).

Implements
IEquatable<Box3>
IFormattable
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: OpenTK.Mathematics
Assembly: OpenTK.Mathematics.dll
Syntax
[Serializable]
public struct Box3 : IEquatable<Box3>, IFormattable

Constructors

Box3(Vector3, Vector3)

Initializes a new instance of the Box3 struct.

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

The minimum point in 3D space this box encloses.

Vector3 max

The maximum point in 3D space this box encloses.

Box3(float, float, float, float, float, float)

Initializes a new instance of the Box3 struct.

Declaration
public Box3(float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
Parameters
Type Name Description
float minX

The minimum X value to be enclosed.

float minY

The minimum Y value to be enclosed.

float minZ

The minimum Z value to be enclosed.

float maxX

The maximum X value to be enclosed.

float maxY

The maximum Y value to be enclosed.

float maxZ

The maximum Z value to be enclosed.

Properties

Center

Gets or sets a vector describing the center of the box.

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

HalfSize

Gets or sets a vector describing half the size of the box.

Declaration
public Vector3 HalfSize { get; set; }
Property Value
Type Description
Vector3

Max

Gets or sets the maximum boundary of the structure.

Declaration
public Vector3 Max { readonly get; set; }
Property Value
Type Description
Vector3

Min

Gets or sets the minimum boundary of the structure.

Declaration
public Vector3 Min { readonly get; set; }
Property Value
Type Description
Vector3

Size

Gets or sets a vector describing the size of the Box3 structure.

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

Methods

Contains(Box3)

Returns whether the box contains the specified box (borders inclusive).

Declaration
[Pure]
public readonly bool Contains(Box3 other)
Parameters
Type Name Description
Box3 other

The box to query.

Returns
Type Description
bool

Whether this box contains the other box.

Contains(Vector3, bool)

Returns whether the box contains the specified point.

Declaration
[Pure]
public bool Contains(Vector3 point, bool boundaryInclusive)
Parameters
Type Name Description
Vector3 point

The point to query.

bool boundaryInclusive

Whether points on the box boundary should be recognised as contained as well.

Returns
Type Description
bool

Whether this box contains the point.

Contains(Vector3)

Returns whether the box contains the specified point (borders inclusive).

Declaration
[Pure]
[Obsolete("This function excludes borders even though it's documentation says otherwise. Use ContainsInclusive and ContainsExclusive for the desired behaviour.")]
public readonly bool Contains(Vector3 point)
Parameters
Type Name Description
Vector3 point

The point to query.

Returns
Type Description
bool

Whether this box contains the point.

ContainsExclusive(Vector3)

Returns whether the box contains the specified point (borders exclusive).

Declaration
[Pure]
public readonly bool ContainsExclusive(Vector3 point)
Parameters
Type Name Description
Vector3 point

The point to query.

Returns
Type Description
bool

Whether this box contains the point.

ContainsInclusive(Vector3)

Returns whether the box contains the specified point (borders inclusive).

Declaration
[Pure]
public readonly bool ContainsInclusive(Vector3 point)
Parameters
Type Name Description
Vector3 point

The point to query.

Returns
Type Description
bool

Whether this box contains the point.

DistanceToNearestEdge(Vector3)

Returns the distance between the nearest edge and the specified point.

Declaration
[Pure]
public readonly float DistanceToNearestEdge(Vector3 point)
Parameters
Type Name Description
Vector3 point

The point to find distance for.

Returns
Type Description
float

The distance between the specified point and the nearest edge.

Equals(Box3)

Declaration
public readonly bool Equals(Box3 other)
Parameters
Type Name Description
Box3 other
Returns
Type Description
bool

Equals(object)

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj
Returns
Type Description
bool
Overrides
ValueType.Equals(object)

Extend(Vector3)

Extend this Box3 to encapsulate a given point.

Declaration
public void Extend(Vector3 point)
Parameters
Type Name Description
Vector3 point

The point to contain.

Extended(Vector3)

Extend this Box3 to encapsulate a given point.

Declaration
[Pure]
public readonly Box3 Extended(Vector3 point)
Parameters
Type Name Description
Vector3 point

The point to contain.

Returns
Type Description
Box3

The inflated box.

GetHashCode()

Declaration
public override readonly int GetHashCode()
Returns
Type Description
int
Overrides
ValueType.GetHashCode()

Inflate(Vector3)

Inflates this Box3 by the given size in all directions. A negative size will shrink the box to a maximum of -HalfSize. Use the Extend(Vector3) method for the point-encapsulation functionality in OpenTK version 4.8.1 and earlier.

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

The size to inflate by.

Inflated(Vector3)

Inflates this Box3 by the given size in all directions. A negative size will shrink the box to a maximum of -HalfSize. Use the Extended(Vector3) method for the point-encapsulation functionality in OpenTK version 4.8.1 and earlier.

Declaration
[Pure]
public readonly Box3 Inflated(Vector3 size)
Parameters
Type Name Description
Vector3 size

The size to inflate by.

Returns
Type Description
Box3

The inflated box.

Scale(Vector3, Vector3)

Scales this Box3 by the given amount.

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

The scale to scale the box.

Vector3 anchor

The anchor to scale the box from.

Scaled(Vector3, Vector3)

Returns a Box3 scaled by a given amount from an anchor point.

Declaration
[Pure]
public readonly Box3 Scaled(Vector3 scale, Vector3 anchor)
Parameters
Type Name Description
Vector3 scale

The scale to scale the box.

Vector3 anchor

The anchor to scale the box from.

Returns
Type Description
Box3

The scaled box.

ToString()

Declaration
public override string ToString()
Returns
Type Description
string
Overrides
ValueType.ToString()

ToString(IFormatProvider)

Declaration
public string ToString(IFormatProvider formatProvider)
Parameters
Type Name Description
IFormatProvider formatProvider
Returns
Type Description
string

ToString(string, IFormatProvider)

Declaration
public string ToString(string format, IFormatProvider formatProvider)
Parameters
Type Name Description
string format
IFormatProvider formatProvider
Returns
Type Description
string

ToString(string)

Declaration
public string ToString(string format)
Parameters
Type Name Description
string format
Returns
Type Description
string

Translate(Vector3)

Translates this Box3 by the given amount.

Declaration
public void Translate(Vector3 distance)
Parameters
Type Name Description
Vector3 distance

The distance to translate the box.

Translated(Vector3)

Returns a Box3 translated by the given amount.

Declaration
[Pure]
public readonly Box3 Translated(Vector3 distance)
Parameters
Type Name Description
Vector3 distance

The distance to translate the box.

Returns
Type Description
Box3

The translated box.

Operators

operator ==(Box3, Box3)

Equality comparator.

Declaration
public static bool operator ==(Box3 left, Box3 right)
Parameters
Type Name Description
Box3 left

The left operand.

Box3 right

The right operand.

Returns
Type Description
bool

operator !=(Box3, Box3)

Inequality comparator.

Declaration
public static bool operator !=(Box3 left, Box3 right)
Parameters
Type Name Description
Box3 left

The left operand.

Box3 right

The right operand.

Returns
Type Description
bool

Implements

IEquatable<T>
IFormattable
In This Article
Back to top Generated by DocFX