Partial fix to static wall generation, add haddocks
This commit is contained in:
+24
-3
@@ -14,19 +14,34 @@ nextPair (_,y) = filter (\(x,_) -> x == y)
|
||||
isLooping :: Eq a => [(a,a)] -> Bool
|
||||
isLooping xs = all (( == 1) . length . flip nextPair xs) xs
|
||||
|
||||
isLooping' :: Eq a => [(a,a)] -> Bool
|
||||
isLooping' xs = all (f xs) xs
|
||||
where
|
||||
f ys (x,y) = length ins == length outs && length rins == length routs
|
||||
where
|
||||
ins = filter (\(a,b) -> a == x) ys
|
||||
outs = filter (\(a,b) -> b == x) ys
|
||||
rins = filter (\(a,b) -> a == y) ys
|
||||
routs = filter (\(a,b) -> b == y) ys
|
||||
|
||||
polygonStrictlyConvex :: [Point2] -> Bool
|
||||
polygonStrictlyConvex ps = True
|
||||
|
||||
--prop_looping :: [Point2] -> [WallP] -> Bool
|
||||
|
||||
prop_looping = forAllShrink genTris shrinkTris $ \tris ->
|
||||
isLooping $ foldr cutWalls' [] tris
|
||||
(all (not . (\[a,b,c] -> isOnLine a b c
|
||||
|| isOnLine a c b
|
||||
|| isOnLine b c a
|
||||
) ) tris)
|
||||
==> (isLooping' $ foldr cutWalls' [] tris)
|
||||
|
||||
shrinkTris (x:xs) = xs : map (x :) (shrink xs)
|
||||
shrinkTris [] = []
|
||||
shrinkTris (x:xs) = xs : map (x :) (shrinkTris xs)
|
||||
|
||||
genTri = zip <$> trip <*> trip
|
||||
where
|
||||
trip = vectorOf 3 $ choose (-500,500::Float)
|
||||
trip = vectorOf 3 $ fmap fromIntegral $ choose (0,5::Int)
|
||||
|
||||
genTris = listOf genTri
|
||||
|
||||
@@ -34,3 +49,9 @@ genTris = listOf genTri
|
||||
--extractLoops [] = []
|
||||
--extractLoops (x:xs) =
|
||||
|
||||
--[[(4.0,10.0),(6.0,2.0),(3.0,0.0)],[(9.0,3.0),(2.0,5.0),(0.0,6.0)]]
|
||||
--
|
||||
--[[(314.0,-396.0),(0.0,-223.71985),(-239.32773,357.25983)],[(0.0,0.0),(-84.0,-177.0),(237.0,-355.5366)]]
|
||||
--
|
||||
--
|
||||
--[[(5.0,2.0),(3.0,5.0),(1.0,2.0)],[(3.0,2.0),(2.0,0.0),(4.0,0.0)],[(5.0,1.0),(3.0,0.0),(3.0,1.0)]]
|
||||
|
||||
Reference in New Issue
Block a user