forked from schell/GeoAlgLib
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest.hs
More file actions
73 lines (56 loc) · 2.31 KB
/
Test.hs
File metadata and controls
73 lines (56 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
--------------------------------------------------------------------------------
-- Copyright (C) 1997, 1998, 2008 Joern Dinkla, www.dinkla.net
--------------------------------------------------------------------------------
--
-- see
-- Joern Dinkla, Geometrische Algorithmen in Haskell, Diploma Thesis,
-- University of Bonn, Germany, 1998.
--
module Tests.Test ( module Tests.Test, module Basics.Random ) where
import Point ( Point1 (..), Point2 (..), Point3 (..), Point4 (..), pointN,
PointN (..), Point ((<*>)) )
import Data.List ( zip4 )
import Basics.Random ( randomInts, randomDoubles )
import Basics.Utilities ( splitsAt )
import Prelude2010
import Prelude ()
--
-- PSEUDO-ZUFLLIGE MENGEN VON PUNKTEN
--
modulo n = map (\ x -> fromIntegral (x `mod` n))
scale k = map (\ x -> k*x)
split d = splitsAt d
to1 :: Num a => [[a]] -> [Point1 a]
to1 = map (\ [x] -> Point1 x)
to2 :: (Num a, Eq a) => [[a]] -> [Point2 a]
to2 = map (\ [x,y] -> Point2 (x,y))
to3 :: (Num a, Eq a) => [[a]] -> [Point3 a]
to3 = map (\ [x,y,z] -> Point3 (x,y,z))
to4 :: Num a => [[a]] -> [Point4 a]
to4 = map (\ [w,x,y,z] -> Point4 (w,x,y,z))
toN :: Num a => [[a]] -> [PointN a]
toN = map pointN
ips1 k n = take n . to1 . split 1 . modulo k
ips2 k n = take n . to2 . split 2 . modulo k
ips3 k n = take n . to3 . split 3 . modulo k
ips4 k n = take n . to4 . split 4 . modulo k
ipsN d k n = take n . toN . split d . modulo k
dps1 k n = take n . to1 . split 1 . scale k
dps2 k n = take n . to2 . split 2 . scale k
dps3 k n = take n . to3 . split 3 . scale k
dps4 k n = take n . to4 . split 4 . scale k
dpsN d k n = take n . toN . split d . scale k
addD ps
= Point2 (0,ym) : Point2 (xm,0) : Point2 (0, -ym) : Point2 (-xm, 0) : ps
where
xm = 2000
ym = 2000
pointsOnC c r n = take n (map ((c+) . (r<*>)) pointsOnUnitCircle)
pointsOnUnitCircle = map point rands
where rands = map (*(2*pi)) (randomDoubles 511 137)
point phi = Point2 (cos phi, sin phi)
pointsInC c r n = take n (map ((c+) . (r<*>)) pointsInUnitCircle)
pointsInUnitCircle = (zipWith point rands rands2)
where rands = map (*(2*pi)) (randomDoubles 511 137)
rands2 = randomDoubles 247 1031
point phi d = Point2 (d * cos phi, d * sin phi)