Hlinting
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-
|
||||
Testing for and finding intersection points.
|
||||
-}
|
||||
module Geometry.Intersect
|
||||
where
|
||||
import Geometry.Data
|
||||
import Control.Applicative
|
||||
|
||||
import Data.Maybe (isNothing)
|
||||
|
||||
-- | If two lines intersect, return 'Just' that point.
|
||||
intersectLineLine' :: Point2 -> Point2 -> Point2 -> Point2 -> Maybe Point2
|
||||
{-# INLINE intersectLineLine' #-}
|
||||
@@ -95,13 +101,12 @@ myIntersectSegSeg a@(ax,ay) b@(bx,by) c@(cx,cy) d@(dx,dy) = case ratIntersectLin
|
||||
-- | Polymorphic intersection of fractional line points.
|
||||
myIntersectLineLine :: (Eq a,Fractional a) => (a,a) -> (a,a) -> (a,a) -> (a,a) -> Maybe (a,a)
|
||||
myIntersectLineLine a@(ax,ay) b c@(cx,cy) d
|
||||
| linGrad a b == Nothing = ((,) ax) <$> axisInt (c *-* (ax,0)) (d *-* (ax,0))
|
||||
| linGrad c d == Nothing = ((,) cx) <$> axisInt (a *-* (cx,0)) (b *-* (cx,0))
|
||||
| isNothing (linGrad a b) = (ax ,) <$> axisInt (c *-* (ax,0)) (d *-* (ax,0))
|
||||
| isNothing (linGrad c d) = (cx ,) <$> axisInt (a *-* (cx,0)) (b *-* (cx,0))
|
||||
| otherwise
|
||||
= case linGrad a b ^-^ linGrad c d of
|
||||
Just 0 -> Nothing
|
||||
_ -> liftA2 (,) newx ((linGrad a b ^*^ newx) ^+^ axisInt a b)
|
||||
|
||||
where
|
||||
(^-^) = liftA2 (-)
|
||||
(^+^) = liftA2 (+)
|
||||
@@ -132,7 +137,6 @@ but is symmetric around 0:
|
||||
(0.0,0.0)
|
||||
|
||||
-}
|
||||
|
||||
roundPoint2 :: Point2 -> Point2
|
||||
roundPoint2 (x,y) = (fromIntegral $ round x,fromIntegral $ round y)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user