gjk2d 0.1.0.2 → 0.1.0.3
raw patch · 2 files changed
+5/−13 lines, 2 filesdep ~linearPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: linear
API changes (from Hackage documentation)
Files
- gjk2d.cabal +2/−2
- src/GJK.hs +3/−11
gjk2d.cabal view
@@ -1,5 +1,5 @@ name: gjk2d-version: 0.1.0.2+version: 0.1.0.3 -- synopsis: description: Yet another 2D GJK collision dection algorithm with Linear homepage: https://github.com/suzumiyasmith/gjk2d#readme@@ -17,7 +17,7 @@ hs-source-dirs: src exposed-modules: GJK build-depends: base >= 4.7 && < 5- , linear >= 1.20 && < 2+ , linear >= 1.21 && < 2 ghc-options: -Wall default-language: Haskell2010
src/GJK.hs view
@@ -5,7 +5,7 @@ ) where -import Linear+import Linear (Epsilon (nearZero), Metric (dot), V2, crossZ, unangle) -- | Convex is represented by its supprot function newtype Convex = Convex { support :: Double -> V2 Double }@@ -14,14 +14,6 @@ minkowskiDifference :: Convex -> Convex -> Convex minkowskiDifference a b = Convex $ (-) <$> support a <*> (support b . (+ pi)) --- | Compute angle of a vector-unAngle :: V2 Double -> Double-unAngle a@(V2 ax ay) =- let alpha = asin $ ay / norm a- in if ax < 0- then pi - alpha- else alpha- -- | Core Logic: Detect if origin point is contained inside a Convex originInside :: Convex -> Bool originInside s =@@ -30,7 +22,7 @@ else doSimplex (support s) a b where a = support s 0- b = support s $ unAngle (-a)+ b = support s $ unangle (-a) -- | Simplex addition till nearZero doSimplex :: (Double -> V2 Double) -> V2 Double -> V2 Double -> Bool@@ -42,7 +34,7 @@ then doSimplex s a c else True)) where- c = s $ unAngle (b - a) + (if axb > 0 then pi / 2 else -pi / 2)+ c = s $ unangle (b - a) + (if axb > 0 then pi / 2 else -pi / 2) axb = crossZ a b axc = crossZ a c bxc = crossZ b c