-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhilbert_test.html
122 lines (96 loc) · 4.31 KB
/
hilbert_test.html
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>foo</title>
<head>
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript" src="qunit.js"></script>
<link rel="stylesheet" href="reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
<script type="text/javascript" src="hilbert.js"></script>
<script type="text/javascript">
$(document).ready(function(){
module("battenburg");
test("battenburgTest", function() {
matrix = new Battenburg(0, 1, 2, 3);
deepEqual(matrix.mirror_x(), new Battenburg(2, 3, 0, 1));
deepEqual(matrix.mirror_x().mirror_x(), matrix);
deepEqual(matrix.rotate_c(), new Battenburg(2, 0, 3, 1));
deepEqual(matrix.rotate_cc(), new Battenburg(1, 3, 0, 2));
deepEqual(matrix.rotate_c().rotate_c().rotate_c().rotate_c(), matrix);
deepEqual(matrix.rotate_cc().rotate_cc().rotate_cc().rotate_cc(), matrix);
});
test("hilbert_2d_to_1dTest", function() {
deepEqual(hilbert_2d_to_1d(0.0, 0.0, 1), 0.0);
deepEqual(hilbert_2d_to_1d(0.5, 0.0, 1), 0.25);
deepEqual(hilbert_2d_to_1d(0.5, 0.5, 1), 0.5);
deepEqual(hilbert_2d_to_1d(0.0, 0.5, 1), 0.75);
deepEqual(hilbert_2d_to_1d(0.0, 0.0, 2), 0.0);
deepEqual(hilbert_2d_to_1d(0.5, 0.0, 2), 0.25);
deepEqual(hilbert_2d_to_1d(0.5, 0.5, 2), 0.5);
deepEqual(hilbert_2d_to_1d(0.0, 0.5, 2), 0.875);
deepEqual(hilbert_2d_to_1d(0.0, 0.0, 3), 0.0);
deepEqual(hilbert_2d_to_1d(0.5, 0.0, 3), 0.25);
deepEqual(hilbert_2d_to_1d(0.5, 0.5, 3), 0.5);
deepEqual(hilbert_2d_to_1d(0.0, 0.5, 3), 0.90625);
deepEqual(hilbert_2d_to_1d(0.0, 0.0, 4), 0.0);
deepEqual(hilbert_2d_to_1d(0.5, 0.0, 4), 0.25);
deepEqual(hilbert_2d_to_1d(0.5, 0.5, 4), 0.5);
deepEqual(hilbert_2d_to_1d(0.0, 0.5, 4), 0.9140625);
deepEqual(hilbert_2d_to_1d(0.0, 0.0, 20), 0.0);
deepEqual(hilbert_2d_to_1d(0.5, 0.0, 20), 0.25);
deepEqual(hilbert_2d_to_1d(0.5, 0.5, 20), 0.5);
deepEqual(hilbert_2d_to_1d(0.0, 0.5, 20), 0.9166666666660603);
// default recursion of 28
deepEqual(hilbert_2d_to_1d(0.0, 0.0), 0.0);
deepEqual(hilbert_2d_to_1d(0.5, 0.0), 0.25);
deepEqual(hilbert_2d_to_1d(0.5, 0.5), 0.5);
deepEqual(hilbert_2d_to_1d(0.0, 0.5), 0.9166666666666666); // tends to 0.75 + 0.25 * 2/3
});
test("hilbert_1d_to_2dTest", function() {
deepEqual(hilbert_1d_to_2d(0.0, 1), [0.0, 0.0]);
deepEqual(hilbert_1d_to_2d(0.25, 1), [0.5, 0.0]);
deepEqual(hilbert_1d_to_2d(0.5, 1), [0.5, 0.5]);
deepEqual(hilbert_1d_to_2d(0.75, 1), [0.0, 0.5]);
deepEqual(hilbert_1d_to_2d(0.0, 2), [0.0, 0.0]);
deepEqual(hilbert_1d_to_2d(0.25, 2), [0.5, 0.0]);
deepEqual(hilbert_1d_to_2d(0.5, 2), [0.5, 0.5]);
deepEqual(hilbert_1d_to_2d(0.875, 2), [0.0, 0.5]);
deepEqual(hilbert_1d_to_2d(0.0, 3), [0.0, 0.0]);
deepEqual(hilbert_1d_to_2d(0.25, 3), [0.5, 0.0]);
deepEqual(hilbert_1d_to_2d(0.5, 3), [0.5, 0.5]);
deepEqual(hilbert_1d_to_2d(0.9140625, 3), [0.0, 0.5]);
deepEqual(hilbert_1d_to_2d(0.0, 20), [0.0, 0.0]);
deepEqual(hilbert_1d_to_2d(0.25, 20), [0.5, 0.0]);
deepEqual(hilbert_1d_to_2d(0.5, 20), [0.5, 0.5]);
deepEqual(hilbert_1d_to_2d(0.9166666666660603, 20), [0.0, 0.5]);
// default recursion of 28
deepEqual(hilbert_1d_to_2d(0.0), [0.0, 0.0]);
deepEqual(hilbert_1d_to_2d(0.25), [0.5, 0.0]);
deepEqual(hilbert_1d_to_2d(0.5), [0.5, 0.5]);
deepEqual(hilbert_1d_to_2d(0.9166666666660603), [9.499490261077881e-7,0.5000009499490261]);
});
test("arbitraryTest", function() {
// default recursion of 28
deepEqual(hilbert_1d_to_2d(0.1), [0.0714285671710968,0.2777777761220932]);
deepEqual(hilbert_1d_to_2d(0.2), [0.2857142873108387,0.1111111156642437]);
deepEqual(hilbert_1d_to_2d(0.3), [0.6428571417927742,0.0555555522441864]);
deepEqual(hilbert_1d_to_2d(0.4), [0.9999999925494194,0.3333333358168602]);
// default recursion of 28
deepEqual(hilbert_2d_to_1d(0.0714285671710968,0.2777777761220932), 0.1);
deepEqual(hilbert_2d_to_1d(0.2857142873108387,0.1111111156642437), 0.2);
deepEqual(hilbert_2d_to_1d(0.6428571417927742,0.0555555522441864), 0.3);
deepEqual(hilbert_2d_to_1d(0.9999999925494194,0.3333333358168602), 0.4);
});
});
</script>
</head>
<body>
<div id="qunit">
<h1 id="qunit-header">QUnit tests</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</div>
</body>
</html>