collidex v0.1.0 Collidex.Utils

Assorted utilities and geometric transformations.

Summary

Functions

Convert the numeric parts of arguments to floats. Accepts a single number, a 2-tuple of numbers, or a list of 2-tuples of numbers

Returns a vector normal to each edge of the shape, in a right-handed coordinate space

Given two numeric ranges {a1, a2}, {b1, b2}, returns true if those ranges overlap

Returns the unit-length version of the vector passed as an argument

Functions

coerce_floats(list)

Convert the numeric parts of arguments to floats. Accepts a single number, a 2-tuple of numbers, or a list of 2-tuples of numbers.

Examples

iex> Collidex.Utils.coerce_floats [ {1, 3}, {-1.5, -2} ] [ {1.0, 3.0}, {-1.5, -2.0} ]

iex> Collidex.Utils.coerce_floats {1, 3} {1.0, 3.0}

iex> Collidex.Utils.coerce_floats 6 6.0

extent_on_axis(shape, axis)
normals_of_edges(polygon)

Returns a vector normal to each edge of the shape, in a right-handed coordinate space.

overlap?(list)
overlap?(arg1, arg2)

Given two numeric ranges {a1, a2}, {b1, b2}, returns true if those ranges overlap.

Examples

iex> Collidex.Utils.overlap?({0.0,5.0}, {5.0, 10.0}) true iex> Collidex.Utils.overlap?({-1.0, -3.0}, {-6.1, 3.5}) true iex> Collidex.Utils.overlap?({-1.0, 0.0}, {0.01, 1.0} ) false

project_onto_axis(arg1, axis)
unit_vector(arg)

Returns the unit-length version of the vector passed as an argument.