packages feed

AC-Vector-Fancy 2.1.0 → 2.1.2

raw patch · 2 files changed

+22/−5 lines, 2 filesdep ~AC-VectorPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: AC-Vector

API changes (from Hackage documentation)

+ Data.BoundingBox: class HasBBox x where { type family BBox x :: *; }
+ Data.BoundingBox: get_bbox :: (HasBBox x) => x -> BBox x
+ Data.BoundingBox: points_bounds :: (BoundingBox b) => [Point b] -> b

Files

AC-Vector-Fancy.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: >= 1.6
 Name:          AC-Vector-Fancy
-Version:       2.1.0
+Version:       2.1.2
 Stability:     Experimental
 Synopsis:      Fancy type system stuff for AC-Vector
 
@@ -10,7 +10,7 @@   (Requires several language extensions, including
   type families.)
 
-  Now includes bounding box classes.
+  Now includes @points_bounds@ method.
 
 Category:      Data, Math, Numerical, Graphics
 License:       BSD3
@@ -26,5 +26,5 @@     Data.Vector.Fancy,
     Data.Vector.Transform.Fancy,
     Data.BoundingBox
-  Build-Depends:   base >= 4 && < 5, AC-Angle >= 1.0, AC-Vector >= 2.1
+  Build-Depends:   base >= 4 && < 5, AC-Angle >= 1.0, AC-Vector >= 2.1.1
   HS-Source-Dirs:  .
Data/BoundingBox.hs view
@@ -6,8 +6,8 @@ 
 module Data.BoundingBox
     (
-      -- * Class
-      BoundingBox (..),
+      -- * Classes
+      BoundingBox (..), HasBBox (..),
 
       -- * Types
 
@@ -40,6 +40,9 @@   -- | Given two corner points, construct a bounding box containing them both. (You can use any two points, given in any order, provided that they are from /opposite/ corners.)
   bounds :: Point b -> Point b -> b
 
+  -- | Given a list of points, construct a bounding box containing them all. (Throws an exception if the list is empty.)
+  points_bounds :: [Point b] -> b
+
   -- | Return a point containing the minimum values for all coordinates.
   min_bound :: b -> Point b
 
@@ -58,6 +61,7 @@ instance BoundingBox R.Range where
   type Point R.Range = Scalar
   bounds        = R.bounds
+  points_bounds = R.points_bounds
   min_bound     = R.min_bound
   max_bound     = R.max_bound
   within_bounds = R.within_bounds
@@ -67,6 +71,7 @@ instance BoundingBox B1.BBox1 where
   type Point B1.BBox1 = Vector1
   bounds        = B1.bounds
+  points_bounds = B1.points_bounds
   min_bound     = B1.min_bound
   max_bound     = B1.max_bound
   within_bounds = B1.within_bounds
@@ -76,6 +81,7 @@ instance BoundingBox B2.BBox2 where
   type Point B2.BBox2 = Vector2
   bounds        = B2.bounds
+  points_bounds = B2.points_bounds
   min_bound     = B2.min_bound
   max_bound     = B2.max_bound
   within_bounds = B2.within_bounds
@@ -85,6 +91,7 @@ instance BoundingBox B3.BBox3 where
   type Point B3.BBox3 = Vector3
   bounds        = B3.bounds
+  points_bounds = B3.points_bounds
   min_bound     = B3.min_bound
   max_bound     = B3.max_bound
   within_bounds = B3.within_bounds
@@ -94,8 +101,18 @@ instance BoundingBox B4.BBox4 where
   type Point B4.BBox4 = Vector4
   bounds        = B4.bounds
+  points_bounds = B4.points_bounds
   min_bound     = B4.min_bound
   max_bound     = B4.max_bound
   within_bounds = B4.within_bounds
   union         = B4.union
   isect         = B4.isect
+
+
+-- | Class representing things that possess a bounding box.
+class HasBBox x where
+  -- | The type of bounding box. (Varies depending in the required number of dimensions.)
+  type BBox x :: *
+
+  -- | Get an object's bounding box.
+  get_bbox :: x -> BBox x