-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataset.h
More file actions
75 lines (66 loc) · 1.63 KB
/
Copy pathdataset.h
File metadata and controls
75 lines (66 loc) · 1.63 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
74
75
#pragma once
#include <cmath>
const double PI = 3.1415926;
inline unsigned int hash1(uint32_t a) {
a = (a + 0x7ed55d16) + (a << 12);
a = (a ^ 0xc761c23c) ^ (a >> 19);
a = (a + 0x165667b1) + (a << 5);
a = (a + 0xd3a2646c) ^ (a << 9);
a = (a + 0xfd7046c5) + (a << 3);
a = (a ^ 0xb55a4f09) ^ (a >> 16);
if (a < 0) a = -a;
return a;
}
inline unsigned int hash2(uint32_t a) {
a = (a + 0x1a976ce5) + (a << 15);
a = (a ^ 0x98bf7c21) ^ (a >> 13);
a = (a + 0xc092738a) + (a << 7);
a = (a + 0xbbc2976e) ^ (a << 9);
a = (a + 0xf6efd123) + (a << 11);
a = (a ^ 0x987abc01) ^ (a >> 2);
if (a < 0) a = -a;
return a;
}
struct point
{
double x, y;
int pivot;
bool operator < (const point &o) const
{
return pivot < o.pivot;
}
bool operator == (const point &o) const
{
return pivot == o.pivot;
}/**/
};
typedef struct facet
{
point v1, v2;
bool operator < (const facet &o) const
{
if (v1.pivot == o.v1.pivot)
return v2.pivot < o.v2.pivot;
return v1.pivot < o.v1.pivot;
}
bool operator == (const facet &o) const
{
return v1.pivot == o.v1.pivot && v2.pivot == o.v2.pivot;
}
}Facet;
bool sortfunction(int i, int j) { return (j < i); }
void RandmPoint(point *p, int n){
for (int i = 0; i < n; i++) {
p[i].x = (hash1(i)) % (n * 2);
p[i].y = (hash2(i)) % (n * 2);
p[i].pivot = i;
}
}
void RandmOnCircle(point *p, int n) {
for (int i = 0; i < n; i++) {
p[i].x = (double)n + n * cos((((hash1(i)) % (n * 100))*360.0) / (100 * n)*PI / 180);
p[i].y = (double)n + n * sin((((hash1(i)) % (n * 100))*360.0) / (100 * n)*PI / 180);
p[i].pivot = i;
}
return;
}