Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
this module provides an implementation of the Gilbert-Johnson-Keerthi (GJK) collision detection algorith for convex objects in 2D. To deal with concave objects, simply break your larger object into smaller convex shapes.
It is very efficient, usually converging in one or two iterations.
Documentation
collision :: Int -> Mink a -> Mink b -> Maybe Bool Source #
Determine if there is a collision between two objects. Object information is given as a pair of: a boundary representation of type a, and a support function for that representaion f :: a -> Pt -> Pt which takes the boundary representation and a direction vector, and returns the point of the boundary furthest along the direction. Pt here is used as an alias for (Double, Double). The first argument to collision is max recursion depth, which might come in handy in the case where you are writing your own support functions.
poly1 = [(-15,-10),(0,15),(12,-5)] poly2 = [(-9,13),(6,13),(-2,22)]
collision 10 (poly1, polySupport) (poly2, polySupport) == Just True