geom2d 0.1.2.0 → 0.1.2.1
raw patch · 2 files changed
+25/−5 lines, 2 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Geom2d.Shape.Internal: Box :: (a, a) -> (a, a) -> Box a
+ Geom2d.Shape.Internal: data Box a
+ Geom2d.Shape.Internal: instance GHC.Classes.Ord a => Geom2d.Intersect.Intersect (Geom2d.Shape.Internal.Box a) (Geom2d.Shape.Internal.Box a)
+ Geom2d.Shape.Internal: spatialBox :: (Floating a, Ord a, Spatial s) => s a -> Box a
Files
- Geom2d/Shape/Internal.hs +24/−4
- geom2d.cabal +1/−1
Geom2d/Shape/Internal.hs view
@@ -14,6 +14,8 @@ , rectangleInt , Shape (..) , Spatial (..)+ , Box (..)+ , spatialBox ) where@@ -223,10 +225,18 @@ instance ( Ord a, Distance p p, Eq (p a) , Num (p a), Point p, RealFloat a) => Intersect (Shape p a) (Shape p a) where- intersect (ShapeCircle c) (ShapePolygon p) = c `intersect` p- intersect (ShapePolygon p) (ShapeCircle c) = c `intersect` p- intersect (ShapeCircle a) (ShapeCircle b) = a `intersect` b- intersect (ShapePolygon a) (ShapePolygon b) = a `intersect` b+ intersect (ShapeCircle c) (ShapePolygon p)+ | not (spatialBox c `intersect` spatialBox p) = False+ | otherwise = c `intersect` p+ intersect (ShapePolygon p) (ShapeCircle c)+ | not (spatialBox c `intersect` spatialBox p) = False+ | otherwise = c `intersect` p+ intersect (ShapeCircle a) (ShapeCircle b)+ | not (spatialBox a `intersect` spatialBox b) = False+ | otherwise = a `intersect` b+ intersect (ShapePolygon a) (ShapePolygon b)+ | not (spatialBox a `intersect` spatialBox b) = False+ | otherwise = a `intersect` b instance ( Floating a, Eq (p a), Num (p a), Ord a, Point p, Distance p p ) => Intersect (Shape p a) (p a) where@@ -297,3 +307,13 @@ minY (ShapePolygon p) = minY p maxY (ShapeCircle c) = maxY c maxY (ShapePolygon p) = maxY p++data Box a = Box (a,a) (a,a)++instance (Ord a) => Intersect (Box a) (Box a) where+ intersect (Box (a1x,a1y) (a2x,a2y)) (Box (b1x,b1y) (b2x,b2y)) =+ max a1x b1x <= min a2x b2x && max a1y b1y <= min a2y b2y++spatialBox :: (Floating a, Ord a, Spatial s) => s a -> Box a+spatialBox o = Box (minX o, minY o) (maxX o, maxY o)+
geom2d.cabal view
@@ -1,5 +1,5 @@ name: geom2d-version: 0.1.2.0+version: 0.1.2.1 synopsis: package for geometry in euklidean 2d space description: This package provides tools for dealing with geometric objects in 2D space.