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

from_points(arg1, arg2)

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}
from_tuple(arg)

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(vector2)

Specs

left_normal(t) :: t

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(v1, v2)

Specs

per_product(t, t) :: float

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
right_normal(vector2)

Specs

right_normal(t) :: t

Right normal of a vector.

Examples

iex> Collision.Vector.Vector2.right_normal(
...>   %Collision.Vector.Vector2{x: 3.0, y: 4.0}
...> )
%Collision.Vector.Vector2{x: -4.0, y: 3.0}