collision v0.3.1 Collision.Vector.Vector2
Two-dimensional vectors used in detecting collisions.
Summary
Functions
Get a vector from a set of points
Convert a tuple to a vector
Left normal of a vector. This is the equivalent of a cross product of a single 2D vector
Per product of a pair of 2D vectors
Right normal of a vector
Types
Functions
Get a vector from a set of points.
Examples
iex> Collision.Vector.Vector2.from_points(%{x: 5, y: 3}, %{x: 10, y: 6})
%Collision.Vector.Vector2{x: 5, y: 3}
Specs
from_tuple({float, float}) :: t
Convert a tuple to a vector.
Examples
iex> Collision.Vector.Vector2.from_tuple({1.0, 1.5})
%Collision.Vector.Vector2{x: 1.0, y: 1.5}
Left normal of a vector. This is the equivalent of a cross product of a single 2D vector.
Examples
iex> Collision.Vector.Vector2.left_normal(
...> %Collision.Vector.Vector2{x: 3.0, y: 4.0}
...> )
%Collision.Vector.Vector2{x: 4.0, y: -3.0}
Per product of a pair of 2D vectors.
Examples
iex> Collision.Vector.Vector2.per_product(
...> %Collision.Vector.Vector2{x: 3.0, y: 4.0},
...> %Collision.Vector.Vector2{x: -1.0, y: 2.0}
...> )
-10.0