wraparound 0.0.1 → 0.0.1.1
raw patch · 2 files changed
+17/−28 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/WrapAround.hs +16/−27
- wraparound.cabal +1/−1
Data/WrapAround.hs view
@@ -13,16 +13,16 @@ of the plane, and a 'WrapPoint', which stores information about the location of the point. + When you need the actual x, y coordinates, use the 'toCoords' conversion+ function.+ A WrapPoint is represented internally as a pair of angles, like in a torus. The WrapMap and WrapPoint structures are kept separate because some WrapPoint calculations can be performed without a WrapMap context. Functions typically only need a WrapMap when a WrapPoint must be converted to actual x, y- coordinates or vice versa. You can perform calculations mixing WrapPoints that- were generated with different WrapMaps, but this generally yields meaningless- results.-- When you need the actual x, y coordinates, use the 'toCoords' conversion- function.+ coordinates or vice versa. Typically you do not want perform calculations with+ WrapPoints that were generated with different WrapMaps, but this is possible+ and sometimes useful. If you are grateful for this software, I gladly accept donations! @@ -115,25 +115,6 @@ let angler' = fixAngle (angler wp1 - angler wp2) in WrapPoint { angleR = angleR', angler = angler' } --- distance :: WrapMap -> WrapPoint -> WrapPoint -> Double--- distance WrapMap { radiusR = mRadiusR, radiusr = mRadiusr }--- WrapPoint { angleR = p1angleR, angler = p1angler }--- WrapPoint { angleR = p2angleR, angler = p2angler }--- = let dXa = abs (p2angler - p1angler) in--- let dYa = abs (p2angleR - p1angleR) in--- let dXb = if p1angler < p2angler--- then abs ((p1angler + 2 * pi) - p2angler)--- else abs ((p1angler - 2 * pi) - p2angler) in--- let dYb = if p1angleR < p2angleR--- then abs ((p1angleR + 2 * pi) - p2angleR)--- else abs ((p1angleR - 2 * pi) - p2angleR) in--- let dX = min dXa dXb in--- let dY = min dYa dYb in--- let dX' = dX * mRadiusr in--- let dY' = dY * mRadiusR in--- sqrt (dX'**2 + dY'**2)-- -- |Finds the distance between two WrapPoints. distance :: WrapMap -- ^ The corresponding WrapMap structure -> WrapPoint -- ^ The first WrapPoint@@ -167,8 +148,16 @@ let dYb = if p1angleR < p2angleR then abs ((p1angleR + 2 * pi) - p2angleR) else abs ((p1angleR - 2 * pi) - p2angleR) in- let dX = min dXa dXb in- let dY = min dYa dYb in+ let dX = if dXa <= dXb+ then p2angler - p1angler+ else if p1angler <= p2angler+ then (p2angler - 2 * pi) - p1angler+ else (p2angler + 2 * pi) - p1angler in+ let dY = if dYa <= dYb+ then p2angleR - p1angleR+ else if p1angleR <= p2angleR+ then (p2angleR - 2 * pi) - p1angleR+ else (p2angleR + 2 * pi) - p1angleR in let dX' = dX * mRadiusr in let dY' = dY * mRadiusR in (dX', dY')
wraparound.cabal view
@@ -3,7 +3,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.0.1+Version: 0.0.1.1 -- A short (one-line) description of the package. Synopsis: Convenient handling of points on a seamless 2-dimensional plane