# Box3D

## Description

`struct` `Tinman.Terrain.Util.Box3D`

A three-dimensional bounding box with 64-bit floating-point precision.

The coordinates refer to infinitesimal points (pixel-is-point semantic).

## Public / Constants

### Empty

`public` `static` `readonly` `attribute` `Empty` → `(Box3D)`

An empty bounding box at the coordinate origin.

Box3D.IsEmpty

### Inverse

`public` `static` `readonly` `attribute` `Inverse` → `(Box3D)`

An inverse bounding box that can be used as the initial value for computing bounds via subsequent calls to `Grow`.

Box3D.IsInverse

### Max

`public` `static` `readonly` `attribute` `Max` → `(Box3D)`

The largest possible box.

Note that the dimension of this box cannot be represented with regular 64-bit floating point numbers and will instead be positive infinity.

## Public / Methods

### Check​Intersection

`[Pure]`
`public` `method` `CheckIntersection1` → `(1)`

box in : Box3D

The other bounding box.

returns → int32

`-1` if the bounding boxes do not overlap, `1` if box in fully contains this bounding box and `0` if both bounding boxes overlap.

Checks the intersection between this bounding box and the given one.

`[Pure]`
`public` `method` `CheckIntersection2` → `(2)`

box in : Box3D

The other bounding box.

toBox in : AffineTransform

The transformation from this bounding box to the given one.

returns → bool

`true` if the bounding boxes intersect each other,
`false` if the bounding boxes do not intersect.

Checks the intersection between this bounding box and the given one.

`[Pure]`
`public` `method` `CheckIntersection3` → `(2)`

ray in : Ray

The ray.

maximum opt : float64 = Maths.MaxDouble

The maximum ray distance to check.

returns → bool

`true` if the ray hits this bounding box, `false` if not.

Checks the intersection between this bounding box and the given ray.

### Clamp

`[Pure]`
`public` `method` `Clamp1` → `(3)`

in : float64

X-coordinate of point.

in : float64

Y-coordinate of point.

in : float64

Z-coordinate of point.

returns → Vec3D

The clamped point.

Clamps the given point to this box.

`[Pure]`
`public` `method` `Clamp2` → `(1)`

in : Vec3D

The point coordinates.

returns → Vec3D

The clamped point.

Clamps the given point to this box.

### Compute​Overlap

`[Pure]`
`public` `method` `ComputeOverlap` → `(1)`

box in : Box3D

Second bounding box.

returns → float64

The amount of overlap (i.e. the volume of the intersection).

Computes the overlap of this bounding box and the given one.

### Contains

`[Pure]`
`public` `method` `Contains1` → `(1)`

xyz in : Vec3D

The point coordinates.

returns → bool

`true` if this box contains the point, `false` if not.

Checks if this box contains the given point.

`[Pure]`
`public` `method` `Contains2` → `(3)`

in : float64

The point X-coordinate.

in : float64

The point Y-coordinate.

in : float64

The point Z-coordinate.

returns → bool

`true` if this box contains the point, `false` if not.

Checks if this box contains the given point.

`[Pure]`
`public` `method` `Contains3` → `(1)`

box in : Box3D

The other box.

returns → bool

`true` if this box fully contains the given box, `false` if not.

Checks if this box contains the given box.

### Disjoint

`[Pure]`
`public` `method` `Disjoint` → `(1)`

box in : Box3D

The other box.

returns → bool

`true` if this box and the given box are disjoint, `false` if not.

Checks if this box and the given box are disjoint (i.e. do not intersect).

### Dot

`[Pure]`
`public` `method` `Dot` → `(2)`

origin in : Vec3D

The origin point.

direction in : Vec3D

The unit-length direction vector.

returns → RangeD

The dot product range.

Computes the dot product range of this box.

### Equals​Almost

`[Pure]`
`public` `method` `EqualsAlmost` → `(1)`

other in : Box3D

The other box

returns → bool

`true` if both boxes are similar, `false` if they are not.

Checks if this box and the given one are similar but necessarily equal.

Maths.Similar2

### From​Points

`[Pure]`
`public` `static` `method` `FromPoints1` → `(6)`

x1 in : float64

X-coordinate of first corner point.

y1 in : float64

Y-coordinate of first corner point.

z1 in : float64

Z-coordinate of first corner point.

x2 in : float64

X-coordinate of second corner point.

y2 in : float64

Y-coordinate of second corner point.

z2 in : float64

Z-coordinate of second corner point.

returns → Box3D

The bounding box.

Creates a new instance of Box3D from the given corner points.

`[Pure]`
`public` `static` `method` `FromPoints2` → `(2)`

in : Vec3D

First corner point.

in : Vec3D

Second corner point.

returns → Box3D

The bounding box.

Creates a new instance of Box3D from the given corner points.

### From​Rect

`[Pure]`
`public` `static` `method` `FromRect` → `(6)`

in : float64

X-coordinate of top-left-front corner of cuboid.

in : float64

Y-coordinate of top-left-front corner of cuboid.

in : float64

Z-coordinate of top-left-front corner of cuboid.

width in : float64

Width of cuboid.

height in : float64

Height of cuboid.

depth in : float64

Depth of cuboid.

returns → Box3D

The bounding box.

Creates a new instance of Box3D from the given rectangular cuboid.

### Grow

`public` `method` `Grow1` → `(1)`

box in : Box3D

To other box.

returns → Box3D

The resulting box.

Enlarges the extends of this box so that it covers the given box.

`public` `method` `Grow2` → `(1)`

in : Vec3D

Coordinates of point to cover (can be NaN).

returns → Box3D

The resulting box.

Enlarges the extends of this box so that it covers the given point.

`public` `method` `Grow3` → `(3)`

in : float64

X-coordinate of point to cover (can be NaN).

in : float64

Y-coordinate of point to cover (can be NaN).

in : float64

Z-coordinate of point to cover (can be NaN).

returns → Box3D

The resulting box.

Enlarges the extends of this box so that it covers the given point.

### Intersect

`[Pure]`
`public` `method` `Intersect` → `(1)`

box in : Box3D

The bounding box.

returns → Box3D

The resulting bounding box.

Computes the intersection of the given bounding box and this one.

`[Pure]`
`public` `method` `Pad` → `(1)`

amount in : float64

The amount to grow.

returns → Box3D

The resulting box

Uniformly pads (i.e. grows) this box by the given amount in.

### Scale

`[Pure]`
`public` `method` `Scale` → `(1)`

factor in : float64

The scale factor.

returns → Box3D

The resulting bounding box.

Scales the coordinates of this bounding box.

### To​Cuboid

`[Pure]`
`public` `method` `ToCuboid` → `()`

returns → Cuboid

The cuboid.

Converts this axis-aligned box to a cuboid.

### Translate

`[Pure]`
`public` `method` `Translate1` → `(1)`

in : Vec3D

The translation vector.

returns → Box3D

The translated bounding box.

Translates this bounding box.

`[Pure]`
`public` `method` `Translate2` → `(3)`

in : float64

Translation amount along X-axis.

in : float64

Translation amount along Y-axis.

in : float64

Translation amount along Z-axis.

returns → Box3D

The resulting bounding box.

Translates this bounding box.

## Public / Attributes

### Center

`public` `attribute` `Center` → `(get)`

value : Vec3D

The coordinates of the box center.

Return the center of this box.

### Depth

`public` `attribute` `Depth` → `(get)`

value : float64

`[>=0]`
The box depth.

Returns the extends of this box along the Z-axis.

### Height

`public` `attribute` `Height` → `(get)`

value : float64

`[>=0]`
The box height.

Returns the extends of this box along the Y-axis.

### Is​Empty

`public` `attribute` `IsEmpty` → `(get)`

value : bool

`true` if this bounding box is empty, `false` if not.

Is this bounding box empty?

The bounding box is empty if its volume is zero.

### Is​Inverse

`public` `attribute` `IsInverse` → `(get)`

value : bool

`true` if this is the inverse bounding box, `false` if not.

Is this the inverse bounding box?

Box3D.Inverse

### Size

`public` `attribute` `Size` → `(get)`

value : Vec3D

The box size: The Width is stored in Vec3D.X, the Height in Vec3D.Y, the Depth in Vec3D.Z.

Returns the size of this box.

### Volume

`public` `attribute` `Volume` → `(get)`

value : float64

`[>=0]`
The bounding box volume.

Returns the volume of this bounding box.

The volume will always be `0` when IsEmpty returns `true`.

### Width

`public` `attribute` `Width` → `(get)`

value : float64

`[>=0]`
The box width.

Returns the extends of this box along the X-axis.

### X1

`public` `readonly` `attribute` `X1` → `(float64)`

X-coordinate of minimum corner of bounding box.

### X2

`public` `readonly` `attribute` `X2` → `(float64)`

X-coordinate of maximum corner of bounding box.

### Y1

`public` `readonly` `attribute` `Y1` → `(float64)`

Y-coordinate of minimum corner of bounding box.

### Y2

`public` `readonly` `attribute` `Y2` → `(float64)`

Y-coordinate of maximum corner of bounding box.

### Z1

`public` `readonly` `attribute` `Z1` → `(float64)`

Z-coordinate of minimum corner of bounding box.

### Z2

`public` `readonly` `attribute` `Z2` → `(float64)`

Z-coordinate of maximum corner of bounding box.

## Serialization

### Serializer

`public` `static` `readonly` `attribute` `Serializer` → `(ITypeSerializer<Box3D>)`

The serialization helper object for values of Box3D.