Struct Box3i
Defines an axis-aligned 3d box (rectangular prism).
Inherited Members
Namespace: OpenTK.Mathematics
Assembly: OpenTK.Mathematics.dll
Syntax
[Serializable]
public struct Box3i : IEquatable<Box3i>, IFormattable
Constructors
Box3i(Vector3i, Vector3i)
Initializes a new instance of the Box3i struct.
Declaration
public Box3i(Vector3i min, Vector3i max)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | min | The minimum point in 3D space this box encloses. |
Vector3i | max | The maximum point in 3D space this box encloses. |
Box3i(int, int, int, int, int, int)
Initializes a new instance of the Box3i struct.
Declaration
public Box3i(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
Parameters
Type | Name | Description |
---|---|---|
int | minX | The minimum X value to be enclosed. |
int | minY | The minimum Y value to be enclosed. |
int | minZ | The minimum Z value to be enclosed. |
int | maxX | The maximum X value to be enclosed. |
int | maxY | The maximum Y value to be enclosed. |
int | maxZ | The maximum Z value to be enclosed. |
Fields
Empty
An empty box with Min (0, 0, 0) and Max (0, 0, 0).
Declaration
public static readonly Box3i Empty
Field Value
Type | Description |
---|---|
Box3i |
UnitSquare
Gets a box with a location 0,0,9 with the a size of 1.
Declaration
public static readonly Box3i UnitSquare
Field Value
Type | Description |
---|---|
Box3i |
Properties
Back
Gets or sets the back location of the box.
Declaration
public int Back { get; set; }
Property Value
Type | Description |
---|---|
int |
Bottom
Gets or sets the bottom location of the box.
Declaration
public int Bottom { get; set; }
Property Value
Type | Description |
---|---|
int |
Center
Gets a vector describing the center of the box.
Declaration
public readonly Vector3 Center { get; }
Property Value
Type | Description |
---|---|
Vector3 |
CenteredSize
Gets a vector describing the size of the Box3i structure.
Declaration
public Vector3i CenteredSize { get; }
Property Value
Type | Description |
---|---|
Vector3i |
Depth
Gets or sets the depth of the box.
Declaration
public int Depth { get; set; }
Property Value
Type | Description |
---|---|
int |
Front
Gets or sets the front location of the box.
Declaration
public int Front { get; set; }
Property Value
Type | Description |
---|---|
int |
HalfSize
Gets or sets a vector describing half the size of the box.
Declaration
public Vector3i HalfSize { get; set; }
Property Value
Type | Description |
---|---|
Vector3i |
Height
Gets or sets the height of the box.
Declaration
public int Height { get; set; }
Property Value
Type | Description |
---|---|
int |
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 int Left { get; set; }
Property Value
Type | Description |
---|---|
int |
Location
Gets the location of the box.
Declaration
public Vector3i Location { get; }
Property Value
Type | Description |
---|---|
Vector3i |
Max
Gets or sets the maximum boundary of the structure.
Declaration
public Vector3i Max { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector3i |
Min
Gets or sets the minimum boundary of the structure.
Declaration
public Vector3i Min { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector3i |
Right
Gets or sets the right location of the box.
Declaration
public int Right { get; set; }
Property Value
Type | Description |
---|---|
int |
Size
Gets or sets the size of the box.
Declaration
public Vector3i Size { get; set; }
Property Value
Type | Description |
---|---|
Vector3i |
SizeX
Gets or sets the horizontal size.
Declaration
public int SizeX { get; set; }
Property Value
Type | Description |
---|---|
int |
SizeY
Gets or sets the vertical size.
Declaration
public int SizeY { get; set; }
Property Value
Type | Description |
---|---|
int |
SizeZ
Gets or sets the vertical size.
Declaration
public int SizeZ { get; set; }
Property Value
Type | Description |
---|---|
int |
Top
Gets or sets the top location of the box.
Declaration
public int Top { get; set; }
Property Value
Type | Description |
---|---|
int |
Width
Gets or sets the width of the box.
Declaration
public int Width { get; set; }
Property Value
Type | Description |
---|---|
int |
X
Gets or sets the X location of the box.
Declaration
public int X { get; set; }
Property Value
Type | Description |
---|---|
int |
Y
Gets or sets the Y location of the box.
Declaration
public int Y { get; set; }
Property Value
Type | Description |
---|---|
int |
Z
Gets or sets the Z location of the box.
Declaration
public int Z { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
Contains(Box3i)
Returns whether the box contains the specified box (borders inclusive).
Declaration
[Pure]
public readonly bool Contains(Box3i other)
Parameters
Type | Name | Description |
---|---|---|
Box3i | other | The box to query. |
Returns
Type | Description |
---|---|
bool | Whether this box contains the other box. |
Contains(Vector3i)
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(Vector3i point)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | point | The point to query. |
Returns
Type | Description |
---|---|
bool | Whether this box contains the point. |
Contains(Vector3i, bool)
Returns whether the box contains the specified point.
Declaration
[Pure]
public bool Contains(Vector3i point, bool boundaryInclusive)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | 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(Vector3i)
Returns whether the box contains the specified point (borders exclusive).
Declaration
[Pure]
public readonly bool ContainsExclusive(Vector3i point)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | point | The point to query. |
Returns
Type | Description |
---|---|
bool | Whether this box contains the point. |
ContainsInclusive(Vector3i)
Returns whether the box contains the specified point (borders inclusive).
Declaration
[Pure]
public readonly bool ContainsInclusive(Vector3i point)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | point | The point to query. |
Returns
Type | Description |
---|---|
bool | Whether this box contains the point. |
DistanceToNearestEdge(Vector3i)
Returns the distance between the nearest edge and the specified point.
Declaration
[Pure]
public readonly float DistanceToNearestEdge(Vector3i point)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | point | The point to find distance for. |
Returns
Type | Description |
---|---|
float | The distance between the specified point and the nearest edge. |
Equals(Box3i)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(Box3i other)
Parameters
Type | Name | Description |
---|---|---|
Box3i | 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(Vector3i)
Extend this Box3i to encapsulate a given point.
Declaration
public void Extend(Vector3i point)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | point | The point to contain. |
Extended(Vector3i)
Extend this Box3i to encapsulate a given point.
Declaration
[Pure]
public readonly Box3i Extended(Vector3i point)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | point | The point to contain. |
Returns
Type | Description |
---|---|
Box3i | The inflated box. |
FromPositions(Vector3i, Vector3i)
Initializes a new instance of the Box3 struct.
Declaration
public static Box3i FromPositions(Vector3i min, Vector3i max)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | min | The minimum point on the XY plane this box encloses. |
Vector3i | max | The maximum point on the XY plane this box encloses. |
Returns
Type | Description |
---|---|
Box3i | A box. |
FromPositions(int, int, int, int, int, int)
Initializes a new instance of the Box3i struct.
Declaration
public static Box3i FromPositions(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
Parameters
Type | Name | Description |
---|---|---|
int | minX | The minimum X value to be enclosed. |
int | minY | The minimum Y value to be enclosed. |
int | minZ | The minimum Z value to be enclosed. |
int | maxX | The maximum X value to be enclosed. |
int | maxY | The maximum Y value to be enclosed. |
int | maxZ | The maximum Z value to be enclosed. |
Returns
Type | Description |
---|---|
Box3i | A box. |
FromSize(Vector3i, Vector3i)
Creates a box.
Declaration
public static Box3i FromSize(Vector3i location, Vector3i size)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | location | The location of the box. |
Vector3i | size | The size of the box. |
Returns
Type | Description |
---|---|
Box3i | 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(Vector3i)
Inflates this Box3i by the given size in all directions. A negative size will shrink the box to a maximum of -HalfSize. Use the Extend(Vector3i) method for the point-encapsulation functionality in OpenTK version 4.8.1 and earlier.
Declaration
public void Inflate(Vector3i size)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | size | The size to inflate by. |
Inflated(Vector3i)
Inflates this Box3i by the given size in all directions. A negative size will shrink the box to a maximum of -HalfSize. Use the Extended(Vector3i) method for the point-encapsulation functionality in eOpenTK version 4.8.1 and earlier.
Declaration
[Pure]
public readonly Box3i Inflated(Vector3i size)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | size | The size to inflate by. |
Returns
Type | Description |
---|---|
Box3i | The inflated box. |
Intersect(Box3i)
Replaces this Box with the intersection of itself and the specified Box.
Declaration
public void Intersect(Box3i other)
Parameters
Type | Name | Description |
---|---|---|
Box3i | other | The Box with which to intersect. |
Intersect(Box3i, Box3i)
Returns the intersection of two Boxes.
Declaration
public static Box3i Intersect(Box3i a, Box3i b)
Parameters
Type | Name | Description |
---|---|---|
Box3i | a | The first box. |
Box3i | b | The second box. |
Returns
Type | Description |
---|---|
Box3i | The intersection of two Boxes. |
Intersected(Box3i)
Returns the intersection of itself and the specified Box.
Declaration
public Box3i Intersected(Box3i other)
Parameters
Type | Name | Description |
---|---|---|
Box3i | other | The Box with which to intersect. |
Returns
Type | Description |
---|---|
Box3i | The intersection of itself and the specified Box. |
IntersectsWith(Box3i)
Determines if this Box intersects with another Box.
Declaration
public bool IntersectsWith(Box3i other)
Parameters
Type | Name | Description |
---|---|---|
Box3i | other | The Box to test. |
Returns
Type | Description |
---|---|
bool | This method returns true if there is any intersection, otherwise false. |
Scale(Vector3i, Vector3i)
Scales this Box3i by the given amount.
Declaration
public void Scale(Vector3i scale, Vector3i anchor)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | scale | The scale to scale the box. |
Vector3i | anchor | The anchor to scale the box from. |
Scaled(Vector3i, Vector3i)
Returns a Box3i scaled by a given amount from an anchor point.
Declaration
[Pure]
public readonly Box3i Scaled(Vector3i scale, Vector3i anchor)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | scale | The scale to scale the box. |
Vector3i | anchor | The anchor to scale the box from. |
Returns
Type | Description |
---|---|
Box3i | 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(Box3i)
Determines if this Box intersects or touches with another Box.
Declaration
public bool TouchWith(Box3i other)
Parameters
Type | Name | Description |
---|---|---|
Box3i | other | The Box to test. |
Returns
Type | Description |
---|---|
bool | This method returns true if there is any intersection or touches, otherwise false. |
Translate(Vector3i)
Translates this Box3i by the given amount.
Declaration
public void Translate(Vector3i distance)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | distance | The distance to translate the box. |
Translated(Vector3i)
Returns a Box3i translated by the given amount.
Declaration
[Pure]
public readonly Box3i Translated(Vector3i distance)
Parameters
Type | Name | Description |
---|---|---|
Vector3i | distance | The distance to translate the box. |
Returns
Type | Description |
---|---|
Box3i | The translated box. |
Union(Box3i, Box3i)
Gets a Box structure that contains the union of two Box structures.
Declaration
public static Box3i Union(Box3i a, Box3i b)
Parameters
Type | Name | Description |
---|---|---|
Box3i | a | A Box to union. |
Box3i | b | a box to union. |
Returns
Type | Description |
---|---|
Box3i | A Box structure that bounds the union of the two Box structures. |
Operators
operator ==(Box3i, Box3i)
Equality comparator.
Declaration
public static bool operator ==(Box3i left, Box3i right)
Parameters
Type | Name | Description |
---|---|---|
Box3i | left | The left operand. |
Box3i | right | The right operand. |
Returns
Type | Description |
---|---|
bool |
operator !=(Box3i, Box3i)
Inequality comparator.
Declaration
public static bool operator !=(Box3i left, Box3i right)
Parameters
Type | Name | Description |
---|---|---|
Box3i | left | The left operand. |
Box3i | right | The right operand. |
Returns
Type | Description |
---|---|
bool |