Files Classes Functions Hierarchy
#include <d2toindex.h>
Public Member Functions | |
| d2toindex (boxcollision const &box_) | |
| Constructor. | |
| d2toindex (particle const *pi_, boxcollision const &box_) | |
| ~d2toindex () | |
| void | reset () |
| intc | index (uintc i) const |
| Access the ith particle's grid index. | |
| void | getsurroundingcells (uint *&nb_, uint &sz, uintc k) |
| Includes k. | |
Public Attributes | |
| particle const * | pi |
| Array of particles set by the client. | |
| boxcollision const & | box |
| Bounding space. | |
| uint * | nb |
| Neighbour cells and self. | |
| uint | W |
| W^2 cell grid, W is set by the client. | |
Definition at line 26 of file d2toindex.h.
| d2toindex::d2toindex | ( | boxcollision const & | box_ | ) |
| d2toindex::d2toindex | ( | particle const * | pi_, | |
| boxcollision const & | box_ | |||
| ) |
| d2toindex::~d2toindex | ( | ) |
Includes k.
Definition at line 58 of file d2toindex.cpp.
Referenced by test03().
00063 { 00064 assert(W!=0); 00065 boolc above = (k>=W); 00066 boolc left = ((k%W)!=0); 00067 boolc below = (k+W<W*W); 00068 boolc right = ((k%W)!=W-1); 00069 00070 uint index(0); 00071 00072 nb[index++] = k; 00073 00074 if (left) 00075 { 00076 nb[index++] = k-1; 00077 if (above) 00078 nb[index++] = k-W-1; 00079 if (below) 00080 nb[index++] = k+W-1; 00081 } 00082 00083 if (right) 00084 { 00085 nb[index++] = k+1; 00086 if (above) 00087 nb[index++] = k-W+1; 00088 if (below) 00089 nb[index++] = k+W+1; 00090 } 00091 00092 if (above) 00093 nb[index++] = k-W; 00094 00095 if (below) 00096 nb[index++] = k+W; 00097 00098 // finish 00099 nb_ = nb; 00100 sz = index; 00101 }
Access the ith particle's grid index.
Definition at line 37 of file d2toindex.cpp.
References box, pi, particle::pos, W, boxcollision::x0, and boxcollision::y0.
Referenced by test03().
00038 { 00039 assert(W!=0); 00040 assert(pi!=0); 00041 00042 particle const & p(pi[i]); 00043 // cout << SHOW(p) << endl; 00044 //double x = (p.pos[0]-box.x0)/(box.x1-box.x0); 00045 //double y = 1.0 - (p.pos[1]-box.y0)/(box.y1-box.y0); 00046 double x = (p.pos[0]-box.x0)*xleninv; 00047 double y = 1.0 - (p.pos[1]-box.y0)*yleninv; 00048 //cout << SHOW(x) << endl; 00049 //cout << SHOW(y) << endl; 00050 int ix = (int)(x*W) % W; 00051 int iy = (int)(y*W) % W; 00052 //cout << SHOW(ix) << endl; 00053 //cout << SHOW(iy) << endl; 00054 return ix + W*iy; 00055 }
| void d2toindex::reset | ( | ) |
Definition at line 29 of file d2toindex.cpp.
References box, boxcollision::x0, boxcollision::x1, boxcollision::y0, and boxcollision::y1.
Referenced by test03().
00030 { 00031 assert(box.x1-box.x0!=0.0); 00032 assert(box.y1-box.y0!=0.0); 00033 xleninv = 1.0/(box.x1-box.x0); 00034 yleninv = 1.0/(box.y1-box.y0); 00035 }
| boxcollision const& d2toindex::box |
Neighbour cells and self.
Cell surrounded by neighbour cells. xxx xox xxx
Definition at line 47 of file d2toindex.h.
Referenced by ~d2toindex().
| particle const* d2toindex::pi |
Array of particles set by the client.
Definition at line 34 of file d2toindex.h.
Referenced by index().
1.5.8