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

struct Box2L in Tinman.Terrain.Util

A two-dimensional bounding box with 64-bit integer precision.

struct Box2L implements IEquatable<Box2L>

Remarks

The coordinates refer to blocks (pixel-is-area semantic).

    0 1 2 3 4 5

0   . . . . . .   X1 := 1, Y1 := 2
1   . . . . . .
2   . # # # . .   X2 := 3, Y2 := 3
3   . # # # . .
4   . . . . . .   Width := 3, Height := 2
5   . . . . . .

Serialization

Serializer

The serialization helper object for values of Box2L.

public static readonly field Serializer
type ITypeSerializer<Box2L>

Public / Constants

Empty

An empty bounding box at the coordinate origin.

public static readonly field Empty
type Box2L

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 Box2L

Public / Attributes

Area

Returns the area of this bounding box.

public property Area { get }
type int64
value The area.

Remarks:

The area will always be 0 when IsEmpty returns true.

BottomLeft

Returns the bottom-left corner of this box (inclusive).

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

BottomRight

Returns the bottom-right corner of this box (inclusive).

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

Center

public property Center { get }
type Vec2L
value

Height

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

public property Height { get }
type int64
value 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 Vec2L
value The box size: The Width is stored in X, the Height in Y.

TopLeft

Returns the top-left corner of this box (inclusive).

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

TopRight

Returns the top-right corner of this box (inclusive).

public property TopRight { get }
type Vec2L
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 int64
value The box width.

X1

X-coordinate of minimum corner of bounding box.

public readonly field X1
type int64

X2

X-coordinate of maximum corner of bounding box.

public readonly field X2
type int64

Y1

Y-coordinate of minimum corner of bounding box.

public readonly field Y1
type int64

Y2

Y-coordinate of maximum corner of bounding box.

public readonly field Y2
type int64

Public / Methods

CheckIntersection

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

[Pure]
public method CheckIntersection (Box2L box)
type int32
params box The 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.

Clamp

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

[Pure]
public method Clamp (int64 x, int64 y)
type Vec2L
params x
  y

ComputeOverlap

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

[Pure]
public method ComputeOverlap (Box2L box)
type int64
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 (Vec2L xy)
type bool
params xy 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 (Box2L 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 (int64 x, int64 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 (Box2L box)
type bool
params box The other box.
returns true if this box and the given box are disjoint, false if not.

Equals

[Pure]
public method Equals (Box2L other)
type bool
params other

FromPoints

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

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

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

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

FromRect

Creates a new instance of Box2L from the given rectangle.

[Pure]
public static method FromRect (int64 x, int64 y, int64 width, int64 height)
type Box2L
params x X-coordinate of top-left corner of rectangle.
  y Y-coordinate of top-left corner of rectangle.
  width Width of rectangle.
  height Height of rectangle.
returns The bounding box.

Grow

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

public method Grow (Box2L box)
type Box2L
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 (Vec2L v)
type Box2L
params v Coordinates of point to cover.
returns The resulting box.

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

public method Grow (int64 x, int64 y)
type Box2L
params x X-coordinate of point to cover.
  y Y-coordinate of point to cover.
returns The resulting box.

Intersect

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

[Pure]
public method Intersect (Box2L box)
type Box2L
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 (int64 x, int64 y)
type Box2L
params x Translation amount along X-axis.
  y Translation amount along Y-axis.
returns The translated bounding box.