Struct Box3d
Defines an axis-aligned 3d box (rectangular prism).
Inherited Members
Namespace: OpenTK.Mathematics
Assembly: OpenTK.Mathematics.dll
Syntax
[Serializable]
public struct Box3d : IEquatable<Box3d>, IFormattable
Constructors
Box3d(Vector3d, Vector3d)
Initializes a new instance of the Box3d struct.
Declaration
public Box3d(Vector3d min, Vector3d max)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | min | The minimum point in 3D space this box encloses. |
Vector3d | max | The maximum point in 3D space this box encloses. |
Box3d(double, double, double, double, double, double)
Initializes a new instance of the Box3d struct.
Declaration
public Box3d(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
Parameters
Type | Name | Description |
---|---|---|
double | minX | The minimum X value to be enclosed. |
double | minY | The minimum Y value to be enclosed. |
double | minZ | The minimum Z value to be enclosed. |
double | maxX | The maximum X value to be enclosed. |
double | maxY | The maximum Y value to be enclosed. |
double | maxZ | The maximum Z value to be enclosed. |
Properties
Center
Gets or sets a vector describing the center of the box.
Declaration
public Vector3d Center { get; set; }
Property Value
Type | Description |
---|---|
Vector3d |
HalfSize
Gets or sets a vector describing half the size of the box.
Declaration
public Vector3d HalfSize { get; set; }
Property Value
Type | Description |
---|---|
Vector3d |
Max
Gets or sets the maximum boundary of the structure.
Declaration
public Vector3d Max { get; set; }
Property Value
Type | Description |
---|---|
Vector3d |
Min
Gets or sets the minimum boundary of the structure.
Declaration
public Vector3d Min { get; set; }
Property Value
Type | Description |
---|---|
Vector3d |
Size
Gets or sets a vector describing the size of the Box3d structure.
Declaration
public Vector3d Size { get; set; }
Property Value
Type | Description |
---|---|
Vector3d |
Methods
Contains(Box3d)
Returns whether the box contains the specified box (borders inclusive).
Declaration
[Pure]
public bool Contains(Box3d other)
Parameters
Type | Name | Description |
---|---|---|
Box3d | other | The box to query. |
Returns
Type | Description |
---|---|
bool | Whether this box contains the other box. |
Contains(Vector3d, bool)
Returns whether the box contains the specified point.
Declaration
[Pure]
public bool Contains(Vector3d point, bool boundaryInclusive)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | 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(Vector3d)
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 bool Contains(Vector3d point)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | point | The point to query. |
Returns
Type | Description |
---|---|
bool | Whether this box contains the point. |
ContainsExclusive(Vector3d)
Returns whether the box contains the specified point (borders exclusive).
Declaration
[Pure]
public bool ContainsExclusive(Vector3d point)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | point | The point to query. |
Returns
Type | Description |
---|---|
bool | Whether this box contains the point. |
ContainsInclusive(Vector3d)
Returns whether the box contains the specified point (borders inclusive).
Declaration
[Pure]
public bool ContainsInclusive(Vector3d point)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | point | The point to query. |
Returns
Type | Description |
---|---|
bool | Whether this box contains the point. |
DistanceToNearestEdge(Vector3d)
Returns the distance between the nearest edge and the specified point.
Declaration
[Pure]
public double DistanceToNearestEdge(Vector3d point)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | point | The point to find distance for. |
Returns
Type | Description |
---|---|
double | The distance between the specified point and the nearest edge. |
Equals(Box3d)
Declaration
public bool Equals(Box3d other)
Parameters
Type | Name | Description |
---|---|---|
Box3d | 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
Extend(Vector3d)
Extend this Box3d to encapsulate a given point.
Declaration
public void Extend(Vector3d point)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | point | The point to contain. |
Extended(Vector3d)
Extend this Box3d to encapsulate a given point.
Declaration
[Pure]
public Box3d Extended(Vector3d point)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | point | The point to contain. |
Returns
Type | Description |
---|---|
Box3d | The inflated box. |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
Inflate(Vector3d)
Inflates this Box3d by the given size in all directions. A negative size will shrink the box to a maximum of -HalfSize. Use the Extend(Vector3d) method for the point-encapsulation functionality in OpenTK version 4.8.1 and earlier.
Declaration
public void Inflate(Vector3d size)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | size | The size to inflate by. |
Inflated(Vector3d)
Inflates this Box3d by the given size in all directions. A negative size will shrink the box to a maximum of -HalfSize. Use the Extended(Vector3d) method for the point-encapsulation functionality in OpenTK version 4.8.1 and earlier.
Declaration
[Pure]
public Box3d Inflated(Vector3d size)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | size | The size to inflate by. |
Returns
Type | Description |
---|---|
Box3d | The inflated box. |
Scale(Vector3d, Vector3d)
Scales this Box3d by the given amount.
Declaration
public void Scale(Vector3d scale, Vector3d anchor)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | scale | The scale to scale the box. |
Vector3d | anchor | The anchor to scale the box from. |
Scaled(Vector3d, Vector3d)
Returns a Box3d scaled by a given amount from an anchor point.
Declaration
[Pure]
public Box3d Scaled(Vector3d scale, Vector3d anchor)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | scale | The scale to scale the box. |
Vector3d | anchor | The anchor to scale the box from. |
Returns
Type | Description |
---|---|
Box3d | The scaled box. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |
Overrides
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(Vector3d)
Translates this Box3d by the given amount.
Declaration
public void Translate(Vector3d distance)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | distance | The distance to translate the box. |
Translated(Vector3d)
Returns a Box3d translated by the given amount.
Declaration
[Pure]
public Box3d Translated(Vector3d distance)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | distance | The distance to translate the box. |
Returns
Type | Description |
---|---|
Box3d | The translated box. |
Operators
operator ==(Box3d, Box3d)
Equality comparator.
Declaration
public static bool operator ==(Box3d left, Box3d right)
Parameters
Type | Name | Description |
---|---|---|
Box3d | left | The left operand. |
Box3d | right | The right operand. |
Returns
Type | Description |
---|---|
bool |
operator !=(Box3d, Box3d)
Inequality comparator.
Declaration
public static bool operator !=(Box3d left, Box3d right)
Parameters
Type | Name | Description |
---|---|---|
Box3d | left | The left operand. |
Box3d | right | The right operand. |
Returns
Type | Description |
---|---|
bool |