Struct Box3
Defines an axis-aligned 3d box (rectangular prism).
Inherited Members
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. |
Fields
Empty
Gets a box with all components zero.
Declaration
public static readonly Box3 Empty
Field Value
Type | Description |
---|---|
Box3 |
UnitSquare
Gets a box with a location 0,0,9 with the a size of 1.
Declaration
public static readonly Box3 UnitSquare
Field Value
Type | Description |
---|---|
Box3 |
Properties
Back
Gets or sets the back location of the box.
Declaration
public float Back { get; set; }
Property Value
Type | Description |
---|---|
float |
Bottom
Gets or sets the bottom location of the box.
Declaration
public float Bottom { get; set; }
Property Value
Type | Description |
---|---|
float |
Center
Gets or sets a vector describing the center of the box.
Declaration
public Vector3 Center { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
CenteredSize
Gets or sets a vector describing the size of the Box3 structure.
Declaration
public Vector3 CenteredSize { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
Depth
Gets or sets the depth of the box.
Declaration
public float Depth { get; set; }
Property Value
Type | Description |
---|---|
float |
Front
Gets or sets the front location of the box.
Declaration
public float Front { get; set; }
Property Value
Type | Description |
---|---|
float |
HalfSize
Gets or sets a vector describing half the size of the box.
Declaration
public Vector3 HalfSize { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
Height
Gets or sets the height of the box.
Declaration
public float Height { get; set; }
Property Value
Type | Description |
---|---|
float |
IsZero
Gets a value indicating whether all values are zero.
Declaration
public bool IsZero { get; }
Property Value
Type | Description |
---|---|
bool |
Left
Gets or sets the left location of the box.
Declaration
public float Left { get; set; }
Property Value
Type | Description |
---|---|
float |
Location
Gets the location of the box.
Declaration
public Vector3 Location { get; }
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 |
Right
Gets or sets the right location of the box.
Declaration
public float Right { get; set; }
Property Value
Type | Description |
---|---|
float |
Size
Gets or sets the size of the box.
Declaration
public Vector3 Size { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
SizeX
Gets or sets the horizontal size.
Declaration
public float SizeX { get; set; }
Property Value
Type | Description |
---|---|
float |
SizeY
Gets or sets the vertical size.
Declaration
public float SizeY { get; set; }
Property Value
Type | Description |
---|---|
float |
SizeZ
Gets or sets the vertical size.
Declaration
public float SizeZ { get; set; }
Property Value
Type | Description |
---|---|
float |
Top
Gets or sets the top location of the box.
Declaration
public float Top { get; set; }
Property Value
Type | Description |
---|---|
float |
Width
Gets or sets the width of the box.
Declaration
public float Width { get; set; }
Property Value
Type | Description |
---|---|
float |
X
Gets or sets the X location of the box.
Declaration
public float X { get; set; }
Property Value
Type | Description |
---|---|
float |
Y
Gets or sets the Y location of the box.
Declaration
public float Y { get; set; }
Property Value
Type | Description |
---|---|
float |
Z
Gets or sets the Z location of the box.
Declaration
public float Z { get; set; }
Property Value
Type | Description |
---|---|
float |
Methods
Ceiling(Box3)
Gets a Box structure that contains rounded up integers.
Declaration
public static Box3i Ceiling(Box3 value)
Parameters
Type | Name | Description |
---|---|---|
Box3 | value | A Box to round. |
Returns
Type | Description |
---|---|
Box3i | A Box structure that contains rounded up integers. |
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)
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. |
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. |
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)
Indicates whether the current object is equal to another object of the same type.
Declaration
public readonly bool Equals(Box3 other)
Parameters
Type | Name | Description |
---|---|---|
Box3 | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Equals(object)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current instance. |
Returns
Type | Description |
---|---|
bool | true if |
Overrides
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. |
Floor(Box3)
Gets a Box structure that contains rounded down integers.
Declaration
public static Box3i Floor(Box3 value)
Parameters
Type | Name | Description |
---|---|---|
Box3 | value | A Box to round. |
Returns
Type | Description |
---|---|
Box3i | A Box structure that contains rounded down integers. |
FromPositions(Vector3, Vector3)
Initializes a new instance of the Box3 struct.
Declaration
public static Box3 FromPositions(Vector3 min, Vector3 max)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | min | The minimum point on the XY plane this box encloses. |
Vector3 | max | The maximum point on the XY plane this box encloses. |
Returns
Type | Description |
---|---|
Box3 | A box. |
FromPositions(float, float, float, float, float, float)
Initializes a new instance of the Box3 struct.
Declaration
public static Box3 FromPositions(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. |
Returns
Type | Description |
---|---|
Box3 | A box. |
FromSize(Vector3, Vector3)
Creates a box.
Declaration
public static Box3 FromSize(Vector3 location, Vector3 size)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | location | The location of the box. |
Vector3 | size | The size of the box. |
Returns
Type | Description |
---|---|
Box3 | A box. |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
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. |
Intersect(Box3)
Replaces this Box with the intersection of itself and the specified Box.
Declaration
public void Intersect(Box3 other)
Parameters
Type | Name | Description |
---|---|---|
Box3 | other | The Box with which to intersect. |
Intersect(Box3, Box3)
Returns the intersection of two Boxes.
Declaration
public static Box3 Intersect(Box3 a, Box3 b)
Parameters
Type | Name | Description |
---|---|---|
Box3 | a | The first box. |
Box3 | b | The second box. |
Returns
Type | Description |
---|---|
Box3 | The intersection of two Boxes. |
Intersected(Box3)
Returns the intersection of itself and the specified Box.
Declaration
public Box3 Intersected(Box3 other)
Parameters
Type | Name | Description |
---|---|---|
Box3 | other | The Box with which to intersect. |
Returns
Type | Description |
---|---|
Box3 | The intersection of itself and the specified Box. |
IntersectsWith(Box3)
Determines if this Box intersects with another Box.
Declaration
public bool IntersectsWith(Box3 other)
Parameters
Type | Name | Description |
---|---|---|
Box3 | other | The Box to test. |
Returns
Type | Description |
---|---|
bool | This method returns true if there is any intersection, otherwise false. |
Round(Box3)
Gets a Box structure that contains rounded integers.
Declaration
public static Box3i Round(Box3 value)
Parameters
Type | Name | Description |
---|---|---|
Box3 | value | A Box to round. |
Returns
Type | Description |
---|---|
Box3i | A Box structure that contains rounded integers. |
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()
Returns the fully qualified type name of this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The fully qualified type name. |
Overrides
ToString(IFormatProvider)
Formats the value of the current instance using the specified format.
Declaration
public string ToString(IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
IFormatProvider | formatProvider | The provider to use to format the value. -or- A null reference ( |
Returns
Type | Description |
---|---|
string | The value of the current instance in the specified format. |
ToString(string)
Formats the value of the current instance using the specified format.
Declaration
public string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
string | format | The format to use. -or- A null reference ( |
Returns
Type | Description |
---|---|
string | The value of the current instance in the specified format. |
ToString(string, IFormatProvider)
Formats the value of the current instance using the specified format.
Declaration
public string ToString(string format, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
string | format | The format to use. -or- A null reference ( |
IFormatProvider | formatProvider | The provider to use to format the value. -or- A null reference ( |
Returns
Type | Description |
---|---|
string | The value of the current instance in the specified format. |
TouchWith(Box3)
Determines if this Box intersects or touches with another Box.
Declaration
public bool TouchWith(Box3 other)
Parameters
Type | Name | Description |
---|---|---|
Box3 | other | The Box to test. |
Returns
Type | Description |
---|---|
bool | This method returns true if there is any intersection or touches, otherwise false. |
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. |
Union(Box3, Box3)
Gets a Box structure that contains the union of two Box structures.
Declaration
public static Box3 Union(Box3 a, Box3 b)
Parameters
Type | Name | Description |
---|---|---|
Box3 | a | A Box to union. |
Box3 | b | a box to union. |
Returns
Type | Description |
---|---|
Box3 | A Box structure that bounds the union of the two Box structures. |
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 |