Skip to content

Instantly share code, notes, and snippets.

@IdahoEv
Created September 14, 2016 21:12
Show Gist options
  • Save IdahoEv/7e1aa4c93357449dfc01885369ee0d65 to your computer and use it in GitHub Desktop.
Save IdahoEv/7e1aa4c93357449dfc01885369ee0d65 to your computer and use it in GitHub Desktop.
defmodule Collidex.ListDetector do
@moduledoc """
Functions responsible for testing lists of geometric primitives for
collisions.
"""
@doc """
Given two lists `list1` and `list2`, will return a list of collisions
found between any shapes in list1 and any shapes in list2.
"""
def find_collisions(list_1, list_2, method \\ :accurate )
def find_collisions(list_1, list_2, method) do
for shape_1 <- list_1,
shape_2 <- list_2,
{ :collision, vector } = Collidex.Detector.collision?(shape_1, shape_2, method) do
{ shape_1, shape_2, vector }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment