AC-Vector 2.3.1 → 2.3.2
raw patch · 2 files changed
+12/−9 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- AC-Vector.cabal +6/−4
- Data/BoundingBox/Range.hs +6/−5
AC-Vector.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: >= 1.6 Name: AC-Vector -Version: 2.3.1 +Version: 2.3.2 Stability: Experimental Synopsis: Efficient geometric vectors and transformations. @@ -13,9 +13,11 @@ category, the package itself has no graphics facilities. It just contains data structures that are useful for graphics work.) - - Added the @unions@ function. (More efficient than - @foldr1 union@.) + . + Changes: + . + * Fixed a stupid bug in @union@. Until now, the function could + sometimes return gibberish answers. Hopefully this is now fixed. Category: Data, Math, Numerical, Graphics License: BSD3
Data/BoundingBox/Range.hs view
@@ -25,14 +25,15 @@ -- | Take the union of two ranges. The resulting 'Range' contains all points that the original ranges contained, plus any points between them (if the original ranges don't overlap). union :: Range -> Range -> Range -union (Range x00 x01) (Range x10 x11) = Range (min x00 x01) (max x01 x11) +union (Range ll lh) (Range rl rh) = Range (min ll rl) (max lh rh) -- | Take the intersection of two ranges. If the ranges do not overlap, the intersection is empty, and 'Nothing' is returned. (This is a good way to check whether two ranges overlap or not.) Otherwise a new 'Range' is returned that contains only the points common to both ranges. isect :: Range -> Range -> Maybe Range -isect (Range x00 x01) (Range x10 x11) = - if x00 < x10 - then if x10 < x01 then Just (Range x10 (min x01 x11)) else Nothing - else if x00 < x11 then Just (Range x00 (min x01 x11)) else Nothing +isect (Range ll lh) (Range rl rh) = + let + nl = max ll rl + nh = min lh rh + in if nl > nh then Nothing else Just (Range nl nh) -- | Efficiently compute the union of a list of ranges. unions :: [Range] -> Range