Apply Hlints
This commit is contained in:
+25
-19
@@ -17,6 +17,7 @@ import Data.List
|
||||
import Data.Maybe
|
||||
|
||||
import Control.Applicative
|
||||
-- TODO add bang patterns
|
||||
|
||||
alongLineBy :: Float -> Point2 -> Point2 -> Point2
|
||||
alongLineBy x a b = a +.+ y *.* normalizeV (b -.- a)
|
||||
@@ -171,10 +172,10 @@ anyPolyssIntersect :: [[Point2]] -> [[Point2]] -> Bool
|
||||
anyPolyssIntersect x y = or $ polysIntersect <$> x <*> y
|
||||
|
||||
nRays :: Int -> [Point2]
|
||||
nRays n = take n $ iterate (rotateV (2*pi/fromIntegral n)) $ (600,0)
|
||||
nRays n = take n $ iterate (rotateV (2*pi/fromIntegral n)) (600,0)
|
||||
|
||||
nRaysRad :: Int -> Float -> [Point2]
|
||||
nRaysRad n x = take n $ iterate (rotateV (2*pi/fromIntegral n)) $ (x,0)
|
||||
nRaysRad n x = take n $ iterate (rotateV (2*pi/fromIntegral n)) (x,0)
|
||||
|
||||
-- angles go from 0 to 2pi, need to work out what is left of another
|
||||
|
||||
@@ -298,22 +299,25 @@ isOnLine l1 l2 p = errorClosestPointOnLineParam 10 l1 (l1 +.+ vNormal (l2 -.- l1
|
||||
-- generate an infinite list, and I don't know why
|
||||
divideLine :: Float -> Point2 -> Point2 -> [Point2]
|
||||
--divideLine x a b = map (\i -> a +.+ (i / (fromIntegral numPoints)) *.* (b -.- a))
|
||||
divideLine x a b = take 5000 $ map (\i -> a +.+ (i / (fromIntegral numPoints) *.* (b -.- a)) )
|
||||
$ map fromIntegral ns
|
||||
where d = dist a b
|
||||
numPoints = max 1 $ ceiling $ d / x
|
||||
ns = [0 .. numPoints]
|
||||
divideLine x a b = take 5000
|
||||
$ map (\i -> a +.+ (fromIntegral i / fromIntegral numPoints *.* (b -.- a)) )
|
||||
ns
|
||||
where
|
||||
d = dist a b
|
||||
numPoints = max 1 $ ceiling $ d / x
|
||||
ns = [0 .. numPoints]
|
||||
|
||||
divideLineOddNumPoints :: Float -> Point2 -> Point2 -> [Point2]
|
||||
--divideLine x a b = map (\i -> a +.+ (i / (fromIntegral numPoints)) *.* (b -.- a))
|
||||
divideLineOddNumPoints x a b = take 5000 $ map (\i -> a +.+ (i / (fromIntegral numPoints) *.* (b -.- a)) )
|
||||
$ map fromIntegral ns
|
||||
where d = dist a b
|
||||
numPoints' = max 1 $ ceiling $ d / x
|
||||
numPoints | even numPoints' = numPoints'
|
||||
| otherwise = numPoints' + 1
|
||||
ns = [0 .. numPoints]
|
||||
|
||||
divideLineOddNumPoints x a b = take 5000
|
||||
$ map (\i -> a +.+ (fromIntegral i / fromIntegral numPoints *.* (b -.- a)) )
|
||||
ns
|
||||
where
|
||||
d = dist a b
|
||||
numPoints' = max 1 $ ceiling $ d / x
|
||||
numPoints | even numPoints' = numPoints'
|
||||
| otherwise = numPoints' + 1
|
||||
ns = [0 .. numPoints]
|
||||
|
||||
-- pulled the following from the haskell wiki
|
||||
-- it seems to produce an infinite loop sometimes
|
||||
@@ -343,7 +347,8 @@ digitalLine (x1,y1) (x2,y2)
|
||||
| x <- intervalList x1 x2 ]
|
||||
| otherwise = [ ( ((x1-x2) * y + y1*x2 - y2*x1) `rdiv` (y1-y2) , y)
|
||||
| y <- intervalList y1 y2 ]
|
||||
where rdiv a b = round $ fromIntegral a / fromIntegral b
|
||||
where
|
||||
rdiv a b = round $ fromIntegral a / fromIntegral b
|
||||
|
||||
intervalList :: Int -> Int -> [Int]
|
||||
intervalList x y
|
||||
@@ -352,10 +357,11 @@ intervalList x y
|
||||
|
||||
divideCircle :: Float -> Point2 -> Float -> [Point2]
|
||||
divideCircle x cen rad = map (cen +.+) $ nPointsOnCirc n rad
|
||||
where n = ceiling $ rad * 2 * pi / x
|
||||
where
|
||||
n = ceiling $ rad * 2 * pi / x
|
||||
|
||||
nPointsOnCirc :: Int -> Float -> [Point2]
|
||||
nPointsOnCirc n rad = take n $ iterate (rotateV (2*pi/fromIntegral n)) $ (rad,0)
|
||||
nPointsOnCirc n rad = take n $ iterate (rotateV (2*pi/fromIntegral n)) (rad,0)
|
||||
|
||||
lineInPolygon :: Point2 -> Point2 -> [Point2] -> Bool
|
||||
lineInPolygon a b ps = pointInPolygon a ps || pointInPolygon b ps
|
||||
@@ -364,7 +370,7 @@ lineInPolygon a b ps = pointInPolygon a ps || pointInPolygon b ps
|
||||
|
||||
makeLoopPairs :: [Point2] -> [(Point2,Point2)]
|
||||
makeLoopPairs [] = error "tried to make loop with empty list of points"
|
||||
makeLoopPairs (x:[]) = error "tried to make loop with singleton list of points"
|
||||
makeLoopPairs [x] = error "tried to make loop with singleton list of points"
|
||||
makeLoopPairs (x:xs) = zip (x:xs) (xs ++ [x])
|
||||
|
||||
-- note the pair is ordered
|
||||
|
||||
Reference in New Issue
Block a user