TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

struct Box2D in Tinman.Terrain.Util

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

struct Box2D implements IEquatable<Box2D>

Remarks

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

Serialization

Serializer

The serialization helper object for values of Box2D.

public static readonly field Serializer
type ITypeSerializer<Box2D>

Public / Constants

Empty

An empty bounding box at the coordinate origin.

public static readonly field Empty
type Box2D

Inverse

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

public static readonly field Inverse
type Box2D

Max

The largest possible box.

public static readonly field Max
type Box2D

Public / Attributes

Area

Returns the volume of this bounding box.

public property Area { get }
type float64
value The bounding box volume.

Remarks:

The volume will always be 0 when IsEmpty returns true.

BottomLeft

Returns the bottom-left corner of this box.

public property BottomLeft { get }
type Vec2D
value The bottom-left corner: X1 is stored in X, Y2 is stored in Y.

BottomRight

Returns the bottom-right corner of this box.

public property BottomRight { get }
type Vec2D
value The bottom-right corner: X2 is stored in X, Y2 is stored in Y.

Center

public property Center { get }
type Vec2D
value

Height

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

public property Height { get }
type float64
value [>=0] The box height.

IsEmpty

Is this bounding box empty?

public property IsEmpty { get }
type bool
value true if this bounding box is empty, false if not.

Size

Returns the size of this box.

public property Size { get }
type Vec2D
value The box size: The Width is stored in X, the Height in Y.

TopLeft

Returns the top-left corner of this box.

public property TopLeft { get }
type Vec2D
value The top-left corner: X1 is stored in X, Y1 is stored in Y.

TopRight

Returns the top-right corner of this box.

public property TopRight { get }
type Vec2D
value The top-right corner: X2 is stored in X, Y1 is stored in Y.

Width

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

public property Width { get }
type float64
value [>=0] The box width.

X1

X-coordinate of minimum corner of bounding box.

public readonly field X1
type float64

X2

X-coordinate of maximum corner of bounding box.

public readonly field X2
type float64

Y1

Y-coordinate of minimum corner of bounding box.

public readonly field Y1
type float64

Y2

Y-coordinate of maximum corner of bounding box.

public readonly field Y2
type float64

Public / Methods

CheckIntersection

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

[Pure]
public method CheckIntersection (Box2D box)
type int32
params box The other bounding box.
returns -1 if the bounding boxes do not overlap, 1 if box fully contains this bounding box and 0 if both bounding boxes overlap without containing each other.

Checks the intersection between this bounding box and the given line segment.

[Pure]
public method CheckIntersection (Vec2D a, Vec2D b)
type int32
params a First point of line segment.
  b Second point of line segment.
returns -1 no intersection.
0 intersection and one line segment point is inside of this box.
1 intersection and both line segment points are inside of this box.
2 intersection and both line segment points are outside of this box.

Checks the intersection between this bounding box and the given line segment.

[Pure]
public method CheckIntersection (float64 ax, float64 ay, float64 bx, float64 by)
type int32
params ax X-coordinate of first point of line segment.
  ay Y-coordinate of first point of line segment.
  bx X-coordinate of second point of line segment.
  by Y-coordinate of second point of line segment.
returns -1 no intersection.
0 intersection and only one line segment point is inside of this box.
1 intersection and both line segment points are inside of this box.
2 intersection and both line segment points are outside of this box.

Clamp

[Pure]
public method Clamp (Vec2D v)
type Vec2D
params v

[Pure]
public method Clamp (float64 x, float64 y)
type Vec2D
params x
  y

ComputeOverlap

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

[Pure]
public method ComputeOverlap (Box2D box)
type float64
params box Second bounding box.
returns [>=0] The amount of overlap (i.e. the volume of the intersection).

Contains

Checks if this box contains the given point.

[Pure]
public method Contains (Vec2D xyz)
type bool
params xyz The point coordinates.
returns true if this box contains the point, false if not.

Checks if this box contains the given box.

[Pure]
public method Contains (Box2D box)
type bool
params box The other box.
returns true if this box fully contains the given box, false if not.

Checks if this box contains the given point.

[Pure]
public method Contains (float64 x, float64 y)
type bool
params x The point X-coordinate.
  y The point Y-coordinate.
returns true if this box contains the point, false if not.

Disjoint

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

[Pure]
public method Disjoint (Box2D box)
type bool
params box The other box.
returns true if this box and the given box are disjoint, false if not.

Equals

Checks if this box is equal to the given box.

[Pure]
public method Equals (Box2D other)
type bool
params other The other box.
returns true if the boxes are equal, false if not.

FromPoints

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

[Pure]
public static method FromPoints (Vec2D a, Vec2D b)
type Box2D
params a First corner point.
  b Second corner point.
returns The bounding box.

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

[Pure]
public static method FromPoints (float64 x1, float64 y1, float64 x2, float64 y2)
type Box2D
params x1 X-coordinate of first corner point.
  y1 Y-coordinate of first corner point.
  x2 X-coordinate of second corner point.
  y2 Y-coordinate of second corner point.
returns The bounding box.

FromRect

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

[Pure]
public static method FromRect (float64 x, float64 y, float64 width, float64 height)
type Box2D
params x X-coordinate of top-left-front corner of cuboid.
  y Y-coordinate of top-left-front corner of cuboid.
  width [>=0] Width of cuboid.
  height [>=0] Height of cuboid.
returns The bounding box.

Grow

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

public method Grow (Box2D box)
type Box2D
params box To other box.
returns The resulting box.

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

public method Grow (Vec2D v)
type Box2D
params v Coordinates of point to cover (can be NaN).
returns The resulting box.

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

public method Grow (float64 x, float64 y)
type Box2D
params x X-coordinate of point to cover (can be NaN).
  y Y-coordinate of point to cover (can be NaN).
returns The resulting box.

Intersect

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

[Pure]
public method Intersect (Box2D box)
type Box2D
params box The bounding box.
returns The resulting bounding box.

ToString

Returns a simple string representation of this bounding box.

[Pure]
public override method ToString ()
type string
returns [not-null] The string representation.

Translate

Translates this bounding box.

[Pure]
public method Translate (float64 x, float64 y)
type Box2D
params x Translation amount along X-axis.
  y Translation amount along Y-axis.
returns The resulting bounding box.