1 #ifndef MB_CART_VECT_HPP
2 #define MB_CART_VECT_HPP
24 d[0] =
d[1] =
d[2] = v;
26 inline CartVect(
double i,
double j,
double k )
103 return d[0] == v[0] &&
d[1] == v[1] &&
d[2] == v[2];
107 return d[0] == val &&
d[1] == val &&
d[2] == val;
110 inline double length()
const;
137 inline void get(
double v[3] )
const
145 inline void get(
float v[3] )
const
147 v[0] =
static_cast< float >(
d[0] );
148 v[1] =
static_cast< float >(
d[1] );
149 v[2] =
static_cast< float >(
d[2] );
155 return CartVect( u[0] + v[0], u[1] + v[1], u[2] + v[2] );
160 return CartVect( u[0] - v[0], u[1] - v[1], u[2] - v[2] );
166 return CartVect( u[1] * v[2] - u[2] * v[1], u[2] * v[0] - u[0] * v[2], u[0] * v[1] - u[1] * v[0] );
172 return u[0] * v[0] + u[1] * v[1] + u[2] * v[2];
177 return *
this = *
this * v;
182 return std::sqrt( *
this % *
this );
187 return d[0] *
d[0] +
d[1] *
d[1] +
d[2] *
d[2];
194 d[0] =
d[1] =
d[2] = 0;
209 double tmp = ( u % v ) / std::sqrt( ( u % u ) * ( v % v ) );
210 if( tmp > 1. ) tmp = 1.;
211 if( tmp < -1. ) tmp = -1.;
212 return std::acos( tmp );
221 double tmp = ( u % v ) ;
222 if( tmp - 1. >= - 1.e-12 )
224 double dist = (u - v).
length();
228 if( tmp < -1. ) tmp = -1.;
229 return std::acos( tmp );
234 return CartVect( -v[0], -v[1], -v[2] );
238 return CartVect( v[0] + s, v[1] + s, v[2] + s );
242 return CartVect( v[0] - s, v[1] - s, v[2] - s );
246 return CartVect( v[0] * s, v[1] * s, v[2] * s );
250 return CartVect( v[0] / s, v[1] / s, v[2] / s );
254 return CartVect( v[0] + s, v[1] + s, v[2] + s );
258 return CartVect( v[0] - s, v[1] - s, v[2] - s );
262 return CartVect( v[0] * s, v[1] * s, v[2] * s );
268 const double len = v.
length();
269 return CartVect( v[0] / len, v[1] / len, v[2] / len );
272 std::ostream&
operator<<( std::ostream& s,
const CartVect& v );