shapes-0.1.0.0: physics engine and other tools for 2D shapes

Safe HaskellNone
LanguageHaskell2010

Physics.Contact.GJK

Description

Gilbert-Johnson-Keerthi (GJK) for finding the closest part of a Minkowski space to the origin.

Choose a simplex using opposite extents along some axis. Extend the simplex in the direction of the origin. If the simplex encloses the origin, stop.

based on slides/video by Casey Muratori: * https://www.youtube.com/watch?v=Qupqu1xe7Io

The loop of GJK is:

  • extend the simplex along the search direction
  • shift to the closest component of the simplex
  • do this until we can't extend the simplex any more (search stopped short of the origin)

Synopsis

Documentation

data Simplex3 Source #

2-simplex. The first element is the most recently added. (like the head of a list)

shiftSimplex2 Source #

Arguments

:: Simplex2

1D simplex of 2 points

-> P2

origin (the target point)

-> (Simplex12, V2)

new simplex, new search direction

shiftSimplex3 Source #

Arguments

:: Simplex3

2D simplex of 3 points

-> P2

origin (the target point)

-> Maybe (Simplex12, V2)

(new simplex, new search direction) OR simplex encloses the origin!