collidex v0.2.0 Collidex.Geometry.Rect

Struct to represent grid-aligned rectangles as a pair of points (A and B).

Summary

Functions

Return the geometric center of a rect as a 2-tuple

Make a Rect. Numbers are coerced to floats. Accepts any of: * Four arguments: e.g. x1, y1, x2, y2 * Two vertices as 2-tuples: e.g. { x1, y1}, {x2, y2} * A 4-tuple: e.g. { x1, y1}, {x2, y2}

Functions

center(rect)

Return the geometric center of a rect as a 2-tuple.

make(arg)

Make a Rect. Numbers are coerced to floats. Accepts any of: * Four arguments: e.g. x1, y1, x2, y2 * Two vertices as 2-tuples: e.g. { x1, y1}, {x2, y2} * A 4-tuple: e.g. { x1, y1}, {x2, y2}

Examples

iex> Collidex.Geometry.Rect.make( 1, 2, 50.1, 51.1 )
%Collidex.Geometry.Rect{a: {1.0, 2.0}, b: { 50.1, 51.1}}

iex> Collidex.Geometry.Rect.make({ 1, 2}, { 50.1, 51.1 })
%Collidex.Geometry.Rect{a: {1.0, 2.0}, b: { 50.1, 51.1}}

iex> Collidex.Geometry.Rect.make({ 1, 2, 50.1, 51.1 })
%Collidex.Geometry.Rect{a: {1.0, 2.0}, b: { 50.1, 51.1}}

make(arg1, arg2)
make(x1, y1, x2, y2)