Box2D

Description

struct Tinman.Terrain.Util.Box2D

A two-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 → (Box2D)

An empty bounding box at the coordinate origin.

See also

Box2D.IsEmpty

Inverse


public static readonly attribute Inverse → (Box2D)

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

See also

Box2D.IsInverse

Max


public static readonly attribute Max → (Box2D)

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 / Constructors

From​Points

2 overloads


[Pure]
public static method FromPoints1 → (4)

x1 in : float64

X-coordinate of first corner point.

y1 in : float64

Y-coordinate of first corner point.

x2 in : float64

X-coordinate of second corner point.

y2 in : float64

Y-coordinate of second corner point.

returns → Box2D

The bounding box.

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


[Pure]
public static method FromPoints2 → (2)

in : Vec2D

First corner point.

in : Vec2D

Second corner point.

returns → Box2D

The bounding box.

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

From​Rect


[Pure]
public static method FromRect → (4)

in : float64

X-coordinate of first corner point.

in : float64

Y-coordinate of first corner point.

width in : float64

Width of rectangle.

height in : float64

Height of rectangle.

returns → Box2D

The bounding box.

Creates a new instance of Box2D from the given rectangle.

Public / Methods

Check​Intersection

3 overloads


[Pure]
public method CheckIntersection2 → (2)

in : Vec2D

First point of line segment.

in : Vec2D

Second point of line segment.

returns → int32

-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 CheckIntersection3 → (4)

ax in : float64

X-coordinate of first point of line segment.

ay in : float64

Y-coordinate of first point of line segment.

bx in : float64

X-coordinate of second point of line segment.

by in : float64

Y-coordinate of second point of line segment.

returns → int32

-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.

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

Check​Intersection​Edges


[Pure]
public method CheckIntersectionEdges → (4)

ax in : float64

X-coordinate of first point of line segment.

ay in : float64

Y-coordinate of first point of line segment.

bx in : float64

X-coordinate of second point of line segment.

by in : float64

Y-coordinate of second point of line segment.

returns → bool

true if the line segment intersects with any edge of the given box,
false if there is no intersection.

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

Public / Attributes

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.

Serialization

Serializer


public static readonly attribute Serializer → (ITypeSerializer<Box2D>)

The serialization helper object for values of Box2D.