Last change
on this file since 16560 was 16560, checked in by Mathieu Morlighem, 11 years ago |
merged trunk-jpl and trunk for revision 16554
|
File size:
761 bytes
|
Line | |
---|
1 | #include <cstdio>
|
---|
2 | #include <cstring>
|
---|
3 | #include <cmath>
|
---|
4 | #include <ctime>
|
---|
5 |
|
---|
6 | #include "Direction.h"
|
---|
7 |
|
---|
8 | namespace bamg {
|
---|
9 |
|
---|
10 | /*Constructors/Destructors*/
|
---|
11 | /*FUNCTION Direction() {{{*/
|
---|
12 | Direction::Direction():
|
---|
13 | dir(MaxICoor){
|
---|
14 |
|
---|
15 | }/*}}}*/
|
---|
16 | /*FUNCTION Direction(Icoor1 i,Icoor1 j) {{{*/
|
---|
17 | Direction::Direction(Icoor1 i,Icoor1 j) {
|
---|
18 | Icoor2 n2 = 2*(Abs(i)+Abs(j));
|
---|
19 | Icoor2 r = MaxICoor* (Icoor2) i;
|
---|
20 | Icoor1 r1 = (Icoor1) (2*(r/ n2)); // odd number
|
---|
21 | dir = (j>0) ? r1 : r1+1; // odd-> j>0 even-> j<0
|
---|
22 | }/*}}}*/
|
---|
23 |
|
---|
24 | /*Methods*/
|
---|
25 | /*FUNCTION Direction::direction{{{*/
|
---|
26 | int Direction::direction(Icoor1 i,Icoor1 j) {
|
---|
27 | int r =1;
|
---|
28 | if (dir!= MaxICoor) {
|
---|
29 | Icoor2 x(dir/2),y1(MaxICoor/2-Abs(x)),y((dir%2)?-y1:y1);
|
---|
30 | r = (x*i + y*j) >=0;
|
---|
31 | }
|
---|
32 | return r;
|
---|
33 | }
|
---|
34 | /*}}}*/
|
---|
35 |
|
---|
36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.