| 132 |
|
* @see #vector::dot |
| 133 |
|
*/ |
| 134 |
|
template<typename Real> |
| 135 |
< |
Vector3<Real> cross( const Vector3<Real>& v1, const Vector3<Real>& v2 ) { |
| 135 |
> |
inline Vector3<Real> cross( const Vector3<Real>& v1, const Vector3<Real>& v2 ) { |
| 136 |
|
Vector3<Real> result; |
| 137 |
|
|
| 138 |
|
result.x() = v1.y() * v2.z() - v1.z() * v2.y(); |
| 142 |
|
return result; |
| 143 |
|
} |
| 144 |
|
|
| 145 |
+ |
|
| 146 |
+ |
/** |
| 147 |
+ |
* Returns the linear indexing for integer vectors. Compare to |
| 148 |
+ |
* Rapaport's VLinear |
| 149 |
+ |
* |
| 150 |
+ |
* @param p first vector |
| 151 |
+ |
* @param s second vector |
| 152 |
+ |
*/ |
| 153 |
+ |
template<typename Real> |
| 154 |
+ |
inline Real Vlinear( const Vector3<Real>& p, const Vector3<Real>& s ) { |
| 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; |
| 181 |
|
const Vector3d V3Zero(0.0 , 0.0, 0.0); |
| 182 |
|
const Vector3d V3X( 1.0, 0.0, 0.0 ) ; |
| 183 |
|
const Vector3d V3Y( 0.0, 1.0, 0.0 ) ; |
| 184 |
< |
const Vector3d V3Z ( 0.0, 0.0, 1.0 ) ; |
| 185 |
< |
|
| 184 |
> |
const Vector3d V3Z ( 0.0, 0.0, 1.0 ) ; |
| 185 |
> |
|
| 186 |
|
} |
| 187 |
|
|
| 188 |
|
#endif |