Show / Hide Table of Contents

Struct Box3d

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

Implements
IEquatable<Box3d>
IFormattable
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
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.

Fields

Empty

Gets a box with all components zero.

Declaration
public static readonly Box3d Empty
Field Value
Type Description
Box3d

UnitSquare

Gets a box with a location 0,0,9 with the a size of 1.

Declaration
public static readonly Box3d UnitSquare
Field Value
Type Description
Box3d

Properties

Back

Gets or sets the back location of the box.

Declaration
public double Back { get; set; }
Property Value
Type Description
double

Bottom

Gets or sets the bottom location of the box.

Declaration
public double Bottom { get; set; }
Property Value
Type Description
double

Center

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

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

CenteredSize

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

Declaration
public Vector3d CenteredSize { get; set; }
Property Value
Type Description
Vector3d

Depth

Gets or sets the depth of the box.

Declaration
public double Depth { get; set; }
Property Value
Type Description
double

Front

Gets or sets the front location of the box.

Declaration
public double Front { get; set; }
Property Value
Type Description
double

HalfSize

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

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

Height

Gets or sets the height of the box.

Declaration
public double Height { get; set; }
Property Value
Type Description
double

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 double Left { get; set; }
Property Value
Type Description
double

Location

Gets the location of the box.

Declaration
public Vector3d Location { get; }
Property Value
Type Description
Vector3d

Max

Gets or sets the maximum boundary of the structure.

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

Min

Gets or sets the minimum boundary of the structure.

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

Right

Gets or sets the right location of the box.

Declaration
public double Right { get; set; }
Property Value
Type Description
double

Size

Gets or sets the size of the box.

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

SizeX

Gets or sets the horizontal size.

Declaration
public double SizeX { get; set; }
Property Value
Type Description
double

SizeY

Gets or sets the vertical size.

Declaration
public double SizeY { get; set; }
Property Value
Type Description
double

SizeZ

Gets or sets the vertical size.

Declaration
public double SizeZ { get; set; }
Property Value
Type Description
double

Top

Gets or sets the top location of the box.

Declaration
public double Top { get; set; }
Property Value
Type Description
double

Width

Gets or sets the width of the box.

Declaration
public double Width { get; set; }
Property Value
Type Description
double

X

Gets or sets the X location of the box.

Declaration
public double X { get; set; }
Property Value
Type Description
double

Y

Gets or sets the Y location of the box.

Declaration
public double Y { get; set; }
Property Value
Type Description
double

Z

Gets or sets the Z location of the box.

Declaration
public double Z { get; set; }
Property Value
Type Description
double

Methods

Ceiling(Box3d)

Gets a Box structure that contains rounded up integers.

Declaration
public static Box3i Ceiling(Box3d value)
Parameters
Type Name Description
Box3d value

A Box to round.

Returns
Type Description
Box3i

A Box structure that contains rounded up integers.

Contains(Box3d)

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

Declaration
[Pure]
public readonly 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)

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(Vector3d point)
Parameters
Type Name Description
Vector3d point

The point to query.

Returns
Type Description
bool

Whether this box contains the point.

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.

ContainsExclusive(Vector3d)

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

Declaration
[Pure]
public readonly 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 readonly 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 readonly 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)

Indicates whether the current object is equal to another object of the same type.

Declaration
public bool Equals(Box3d other)
Parameters
Type Name Description
Box3d other

An object to compare with this object.

Returns
Type Description
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.

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 obj and this instance are the same type and represent the same value; otherwise, false.

Overrides
ValueType.Equals(object)

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 readonly Box3d Extended(Vector3d point)
Parameters
Type Name Description
Vector3d point

The point to contain.

Returns
Type Description
Box3d

The inflated box.

Floor(Box3d)

Gets a Box structure that contains rounded down integers.

Declaration
public static Box3i Floor(Box3d value)
Parameters
Type Name Description
Box3d value

A Box to round.

Returns
Type Description
Box3i

A Box structure that contains rounded down integers.

FromPositions(Vector3d, Vector3d)

Initializes a new instance of the Box3 struct.

Declaration
public static Box3d FromPositions(Vector3d min, Vector3d max)
Parameters
Type Name Description
Vector3d min

The minimum point on the XY plane this box encloses.

Vector3d max

The maximum point on the XY plane this box encloses.

Returns
Type Description
Box3d

A box.

FromPositions(double, double, double, double, double, double)

Initializes a new instance of the Box3d struct.

Declaration
public static Box3d FromPositions(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.

Returns
Type Description
Box3d

A box.

FromSize(Vector3d, Vector3d)

Creates a box.

Declaration
public static Box3d FromSize(Vector3d location, Vector3d size)
Parameters
Type Name Description
Vector3d location

The location of the box.

Vector3d size

The size of the box.

Returns
Type Description
Box3d

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
ValueType.GetHashCode()

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 readonly Box3d Inflated(Vector3d size)
Parameters
Type Name Description
Vector3d size

The size to inflate by.

Returns
Type Description
Box3d

The inflated box.

Intersect(Box3d)

Replaces this Box with the intersection of itself and the specified Box.

Declaration
public void Intersect(Box3d other)
Parameters
Type Name Description
Box3d other

The Box with which to intersect.

Intersect(Box3d, Box3d)

Returns the intersection of two Boxes.

Declaration
public static Box3d Intersect(Box3d a, Box3d b)
Parameters
Type Name Description
Box3d a

The first box.

Box3d b

The second box.

Returns
Type Description
Box3d

The intersection of two Boxes.

Intersected(Box3d)

Returns the intersection of itself and the specified Box.

Declaration
public Box3d Intersected(Box3d other)
Parameters
Type Name Description
Box3d other

The Box with which to intersect.

Returns
Type Description
Box3d

The intersection of itself and the specified Box.

IntersectsWith(Box3d)

Determines if this Box intersects with another Box.

Declaration
public bool IntersectsWith(Box3d other)
Parameters
Type Name Description
Box3d other

The Box to test.

Returns
Type Description
bool

This method returns true if there is any intersection, otherwise false.

Round(Box3d)

Gets a Box structure that contains rounded integers.

Declaration
public static Box3i Round(Box3d value)
Parameters
Type Name Description
Box3d value

A Box to round.

Returns
Type Description
Box3i

A Box structure that contains rounded integers.

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 readonly 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()

Returns the fully qualified type name of this instance.

Declaration
public override string ToString()
Returns
Type Description
string

The fully qualified type name.

Overrides
ValueType.ToString()

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 (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

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 (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

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 (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

IFormatProvider formatProvider

The provider to use to format the value.

-or-

A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Returns
Type Description
string

The value of the current instance in the specified format.

TouchWith(Box3d)

Determines if this Box intersects or touches with another Box.

Declaration
public bool TouchWith(Box3d other)
Parameters
Type Name Description
Box3d other

The Box to test.

Returns
Type Description
bool

This method returns true if there is any intersection or touches, otherwise false.

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 readonly Box3d Translated(Vector3d distance)
Parameters
Type Name Description
Vector3d distance

The distance to translate the box.

Returns
Type Description
Box3d

The translated box.

Union(Box3d, Box3d)

Gets a Box structure that contains the union of two Box structures.

Declaration
public static Box3d Union(Box3d a, Box3d b)
Parameters
Type Name Description
Box3d a

A Box to union.

Box3d b

a box to union.

Returns
Type Description
Box3d

A Box structure that bounds the union of the two Box structures.

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

Implements

IEquatable<T>
IFormattable
In this article
Back to top Generated by DocFX