| 155 |
|
return (p.z() * s.y() + p.y()) * s.x() + p.x(); |
| 156 |
|
} |
| 157 |
|
|
| 158 |
+ |
/** |
| 159 |
+ |
* Returns integer vector for the linear index. |
| 160 |
+ |
* |
| 161 |
+ |
* @param i linear position |
| 162 |
+ |
* @param s vector |
| 163 |
+ |
*/ |
| 164 |
+ |
template<typename Real> |
| 165 |
+ |
inline Vector3<Real> idxToV( const Real i, const Vector3<Real>& s ) { |
| 166 |
+ |
Vector3<Real> v; |
| 167 |
+ |
|
| 168 |
+ |
int boxXY = s.y() * s.x(); |
| 169 |
+ |
int remXY = i % boxXY; |
| 170 |
+ |
|
| 171 |
+ |
v.z() = i / boxXY; |
| 172 |
+ |
v.y() = remXY / s.x(); |
| 173 |
+ |
v.x() = remXY % s.x(); |
| 174 |
+ |
return v; |
| 175 |
+ |
} |
| 176 |
+ |
|
| 177 |
|
typedef Vector3<int> Vector3i; |
| 178 |
|
|
| 179 |
|
typedef Vector3<RealType> Vector3d; |