Bounds

csharp
public struct Bounds : IEquatable<Bounds>, IFormattable

Namespace NodeWorld.Flux.

An axis-aligned box: center and extents (half size).

Constructors

Bounds

csharp
public Bounds(Vector3 center, Vector3 size)

The box of this center and size.

Properties

center

csharp
public Vector3 center { get; set; }

The center of the box.

size

csharp
public Vector3 size { get; set; }

The size of the box (twice the extents).

extents

csharp
public Vector3 extents { get; set; }

Half the size of the box.

min

csharp
public Vector3 min { get; set; }

The corner with the smallest x, y and z.

max

csharp
public Vector3 max { get; set; }

The corner with the largest x, y and z.

Methods

SetMinMax

csharp
public void SetMinMax(Vector3 min, Vector3 max)

Makes it the box from min to max.

Encapsulate

csharp
public void Encapsulate(Vector3 point)

Grows the box to hold point.

csharp
public void Encapsulate(Bounds bounds)

Grows the box to hold bounds.

Expand

csharp
public void Expand(float amount)

Grows the size by amount on every axis.

csharp
public void Expand(Vector3 amount)

Grows the size by amount, axis by axis.

Contains

csharp
public bool Contains(Vector3 point)

point is inside the box or on its faces.

Intersects

csharp
public bool Intersects(Bounds bounds)

The two boxes overlap or touch.

ClosestPoint

csharp
public Vector3 ClosestPoint(Vector3 point)

The point of the box nearest to point (point itself when inside).

SqrDistance

csharp
public float SqrDistance(Vector3 point)

The squared distance from point to the box (0 inside).

IntersectRay

csharp
public bool IntersectRay(Ray ray, out float distance)

Slab test: true if the ray hits the box; distance is 0 when the origin is inside.

csharp
public bool IntersectRay(Ray ray)

The ray hits the box.

Equals

csharp
public bool Equals(Bounds other)

The two boxes have the same center and extents.

csharp
public override bool Equals(object other)

other is a box with the same center and extents.

GetHashCode

csharp
public override int GetHashCode()

A hash of the center and the extents.

ToString

csharp
public override string ToString()

"Center: (x, y, z), Extents: (x, y, z)", with 2 decimals.

csharp
public string ToString(string format)

The same text with the numbers in format.

csharp
public string ToString(string format, IFormatProvider formatProvider)

The same text with the numbers in format (F2 when empty) and formatProvider (the invariant culture when null).

Operators

operator ==

csharp
public static bool operator ==(Bounds lhs, Bounds rhs)

The two boxes have the same center and extents.

operator !=

csharp
public static bool operator !=(Bounds lhs, Bounds rhs)

The two boxes differ.