-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrotate.cxx
More file actions
58 lines (41 loc) · 1.04 KB
/
rotate.cxx
File metadata and controls
58 lines (41 loc) · 1.04 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
#include <iostream>
void uvMapping(unsigned layer, std::pair<int,int> &uv) {
unsigned sector(0);
int offset;
if(layer<=28) { // CE-E
if(uv.first>0 && uv.second>=0) return;
offset=0;
if(uv.first>=uv.second && uv.second<0) sector=2;
else sector=1;
} else if((layer%2)==1) { // CE-H Odd
if(uv.first>=0 && uv.second>=0) return;
offset=-1;
if(uv.first>uv.second && uv.second<0) sector=2;
else sector=1;
} else { // CE-H Even
if(uv.first>=1 && uv.second>=1) return;
offset=1;
if(uv.first>=uv.second && uv.second<1) sector=2;
else sector=1;
}
int up,vp;
if(sector==1) {
up=uv.second-uv.first;
vp=-uv.first+offset;
} else {
up=-uv.second+offset;
vp=uv.first-uv.second+offset;
}
uv.first=up;
uv.second=vp;
return;
}
int main(int argc, char **argv){
int u = atoi(argv[1]);
int v = atoi(argv[2]);
unsigned layer = atoi(argv[3]);
std::pair<int,int> uv = std::make_pair(u,v);
uvMapping(layer, uv);
std::cout << "c++: " << uv.first << "," << uv.second << std::endl;
return 0;
}