Safe Haskell | None |
---|---|
Language | Haskell2010 |
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)
- data Simplex3 = Simplex3 !Neighborhood !Neighborhood !Neighborhood
- data Simplex2 = Simplex2 !Neighborhood !Neighborhood
- data Simplex1 = Simplex1 !Neighborhood
- type Simplex12 = Either Simplex1 Simplex2
- type Simplex23 = Either Simplex2 Simplex3
- data Simplex
- closestSimplex :: ConvexHull -> P2 -> Simplex
- extendSimplex :: Simplex12 -> Neighborhood -> Maybe Simplex23
- extendSimplex1 :: Simplex1 -> Neighborhood -> Maybe Simplex2
- extendSimplex2 :: Simplex2 -> Neighborhood -> Maybe Simplex3
- shiftSimplex :: Simplex23 -> P2 -> Either (Simplex12, V2) Simplex3
- shiftSimplex2 :: Simplex2 -> P2 -> (Simplex12, V2)
- shiftSimplex3 :: Simplex3 -> P2 -> Maybe (Simplex12, V2)
- sameDirection :: V2 -> V2 -> Bool
- mkSimplex3 :: Neighborhood -> Simplex2 -> Simplex3
- mkSimplex2 :: Neighborhood -> Simplex1 -> Simplex2
Documentation
2-simplex. The first element is the most recently added. (like the head of a list)
closestSimplex :: ConvexHull -> P2 -> Simplex Source #
extendSimplex :: Simplex12 -> Neighborhood -> Maybe Simplex23 Source #
extendSimplex1 :: Simplex1 -> Neighborhood -> Maybe Simplex2 Source #
extendSimplex2 :: Simplex2 -> Neighborhood -> Maybe Simplex3 Source #
mkSimplex3 :: Neighborhood -> Simplex2 -> Simplex3 Source #
mkSimplex2 :: Neighborhood -> Simplex1 -> Simplex2 Source #