AC-Vector 2.1.0 → 2.1.1
raw patch · 6 files changed
+42/−4 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.BoundingBox.B1: points_bounds :: [Vector1] -> BBox1
+ Data.BoundingBox.B2: points_bounds :: [Vector2] -> BBox2
+ Data.BoundingBox.B3: points_bounds :: [Vector3] -> BBox3
+ Data.BoundingBox.B4: points_bounds :: [Vector4] -> BBox4
+ Data.BoundingBox.Range: points_bounds :: [Scalar] -> Range
Files
- AC-Vector.cabal +7/−4
- Data/BoundingBox/B1.hs +4/−0
- Data/BoundingBox/B2.hs +8/−0
- Data/BoundingBox/B3.hs +9/−0
- Data/BoundingBox/B4.hs +10/−0
- Data/BoundingBox/Range.hs +4/−0
AC-Vector.cabal view
@@ -1,6 +1,6 @@ Cabal-Version: >= 1.6 Name: AC-Vector -Version: 2.1.0 +Version: 2.1.1 Stability: Experimental Synopsis: Efficient geometric vectors and transformations. @@ -9,10 +9,13 @@ This Haskell library implements several small vectors types with @Double@ fields, with seperate types for each size of vector, and a type class for handling vectors generally. + (Note that although this package is listed in the \"graphics\" + category, the package itself has no graphics facilities. It + just contains data structures that are useful for graphics + work.) - Now includes \"bounding box\" types, useful for graphical work. - (Note that this package itself has no graphics facilities as - such. It just provides data structures useful for graphics.) + Now includes @points_bounds@ functions, for finding the bounds + of a list of points. Category: Data, Math, Numerical, Graphics License: BSD3
Data/BoundingBox/B1.hs view
@@ -15,6 +15,10 @@ bounds :: Vector1 -> Vector1 -> BBox1 bounds (Vector1 xa) (Vector1 xb) = BBox1 $ R.bounds xa xb +-- | Find the bounds of a list of points. (Throws an exception if the list is empty.) +points_bounds :: [Vector1] -> BBox1 +points_bounds = BBox1 . R.points_bounds . map v1x + -- | Test whether a 'Vector1' lies within a 'BBox1'. within_bounds :: Vector1 -> BBox1 -> Bool within_bounds (Vector1 x) (BBox1 r) = x `R.within_bounds` r
Data/BoundingBox/B2.hs view
@@ -27,6 +27,14 @@ bounds :: Vector2 -> Vector2 -> BBox2 bounds (Vector2 xa ya) (Vector2 xb yb) = BBox2 (min xa xb) (min ya yb) (max xa xb) (max ya yb) +-- | Find the bounds of a list of points. (Throws an exception if the list is empty.) +points_bounds :: [Vector2] -> BBox2 +points_bounds ps = + let + xs = map v2x ps + ys = map v2y ps + in BBox2 (minimum xs) (minimum ys) (maximum xs) (maximum ys) + -- | Test whether a given 2D vector is inside this bounding box. within_bounds :: Vector2 -> BBox2 -> Bool within_bounds (Vector2 x y) b =
Data/BoundingBox/B3.hs view
@@ -31,6 +31,15 @@ bounds :: Vector3 -> Vector3 -> BBox3 bounds (Vector3 xa ya za) (Vector3 xb yb zb) = BBox3 (min xa xb) (min ya yb) (min za zb) (max xa xb) (max ya yb) (max za zb) +-- | Find the bounds of a list of points. (Throws an exception if the list is empty.) +points_bounds :: [Vector3] -> BBox3 +points_bounds ps = + let + xs = map v3x ps + ys = map v3y ps + zs = map v3z ps + in BBox3 (minimum xs) (minimum ys) (minimum zs) (maximum xs) (maximum ys) (maximum zs) + -- | Test whether a given 3D vector is inside this bounding box. within_bounds :: Vector3 -> BBox3 -> Bool within_bounds (Vector3 x y z) b =
Data/BoundingBox/B4.hs view
@@ -36,6 +36,16 @@ bounds (Vector4 xa ya za wa) (Vector4 xb yb zb wb) = BBox4 (min xa xb) (min ya yb) (min za zb) (min wa wb) (max xa xb) (max ya yb) (max za zb) (max wa wb) +-- | Find the bounds of a list of points. (Throws an exception if the list is empty.) +points_bounds :: [Vector4] -> BBox4 +points_bounds ps = + let + xs = map v4x ps + ys = map v4y ps + zs = map v4z ps + ws = map v4w ps + in BBox4 (minimum xs) (minimum ys) (minimum zs) (minimum ws) (maximum xs) (maximum ys) (maximum zs) (maximum ws) + -- | Test whether a given 4D vector is inside this bounding box. within_bounds :: Vector4 -> BBox4 -> Bool within_bounds (Vector4 x y z w) b =
Data/BoundingBox/Range.hs view
@@ -15,6 +15,10 @@ bounds :: Scalar -> Scalar -> Range bounds xa xb = Range (min xa xb) (max xa xb) +-- | Find the bounds of a list of points. (Throws an exception if the list is empty.) +points_bounds :: [Scalar] -> Range +points_bounds xs = Range (minimum xs) (maximum xs) + -- | Test whether a given 'Scalar' falls within a particular 'Range'. within_bounds :: Scalar -> Range -> Bool within_bounds x (Range x0 x1) = x0 <= x && x <= x1