Clamped reference points
This commit is contained in:
parent
cd4250336b
commit
c624121e23
@ -56,8 +56,9 @@ giveMapHeight mop (x,z)
|
|||||||
|
|
||||||
-- reference Points
|
-- reference Points
|
||||||
refs :: [(Int, Int)]
|
refs :: [(Int, Int)]
|
||||||
refs = map (tadd (floor x, floor z)) [(-1,-1),(-1,2),(0,0),(0,1),(1,0),(1,1),(2,-1),(2,2)]
|
refs = remdups $ map clmp $ map (tadd (floor x, floor z)) mods
|
||||||
where
|
where
|
||||||
|
mods = [(-1,-1),(-1,2),(0,0),(0,1),(1,0),(1,1),(2,-1),(2,2)]
|
||||||
tadd (a,b) (c,d) = (a+b,c+d)
|
tadd (a,b) (c,d) = (a+b,c+d)
|
||||||
|
|
||||||
-- tupels with reference point and distance
|
-- tupels with reference point and distance
|
||||||
@ -66,6 +67,15 @@ giveMapHeight mop (x,z)
|
|||||||
-- total distance of all for reference point from the point in question
|
-- total distance of all for reference point from the point in question
|
||||||
totald = sum $ map (\(_,d) -> d) tups
|
totald = sum $ map (\(_,d) -> d) tups
|
||||||
|
|
||||||
|
-- clamp, as she is programmed
|
||||||
|
clamp :: (Ord a) => a -> a -> a -> a
|
||||||
|
clamp mn mx = max mn . min mx
|
||||||
|
|
||||||
|
-- clamp for tupels
|
||||||
|
clmp :: (Int, Int) -> (Int, Int)
|
||||||
|
clmp (a,b) = let ((xmin,zmin),(xmax,zmax)) = bounds mop
|
||||||
|
in ((clamp (xmin+2) (xmax-2) a),(clamp (zmin+2) (zmax-2) b))
|
||||||
|
|
||||||
-- Real distance on PlayMap
|
-- Real distance on PlayMap
|
||||||
dist :: (Double, Double) -> (Int, Int) -> Double
|
dist :: (Double, Double) -> (Int, Int) -> Double
|
||||||
dist (x1,z1) pmp = let xf = x1 - realx
|
dist (x1,z1) pmp = let xf = x1 - realx
|
||||||
|
Loading…
Reference in New Issue
Block a user