32 #ifndef Vector3_INCLUDE_ONCE 33 #define Vector3_INCLUDE_ONCE 43 template<
typename T_Scalar>
55 x() = (T_Scalar)other.x();
56 y() = (T_Scalar)other.y();
57 z() = (T_Scalar)other.z();
89 const T_Scalar&
x()
const {
return mScalar[0]; }
90 const T_Scalar&
y()
const {
return mScalar[1]; }
91 const T_Scalar&
z()
const {
return mScalar[2]; }
97 const T_Scalar&
r()
const {
return mScalar[0]; }
98 const T_Scalar&
g()
const {
return mScalar[1]; }
99 const T_Scalar&
b()
const {
return mScalar[2]; }
154 *
this = *
this + other;
159 *
this = *
this - other;
164 *
this = *
this * other;
169 *
this = *
this / other;
201 x() =
y() =
z() = val;
206 return x() == other.
x() &&
y() == other.
y() &&
z() == other.
z();
214 if (
x() != other.
x())
215 return x() < other.
x();
217 if (
y() != other.
y())
218 return y() < other.
y();
220 return z() < other.
z();
233 *
this *= (T_Scalar)(1.0/l);
264 #if VL_PIPELINE_PRECISION == 2 272 inline float dot(
const fvec3& v1,
const fvec3& v2) {
return v1.
x()*v2.
x() + v1.
y()*v2.
y() + v1.
z()*v2.
z(); }
273 inline double dot(
const dvec3& v1,
const dvec3& v2) {
return v1.
x()*v2.
x() + v1.
y()*v2.
y() + v1.
z()*v2.
z(); }
274 inline float dot(
const ivec3& v1,
const ivec3& v2) {
return (
float)(v1.
x()*v2.
x() + v1.
y()*v2.
y() + v1.
z()*v2.
z()); }
275 inline float dot(
const uvec3& v1,
const uvec3& v2) {
return (
float)(v1.
x()*v2.
x() + v1.
y()*v2.
y() + v1.
z()*v2.
z()); }
277 inline fvec3
cross(
const fvec3& v1,
const fvec3& v2)
280 t.
x() = v1.
y()*v2.
z() - v1.
z()*v2.
y();
281 t.
y() = v1.
z()*v2.
x() - v1.
x()*v2.
z();
282 t.
z() = v1.
x()*v2.
y() - v1.
y()*v2.
x();
286 inline dvec3
cross(
const dvec3& v1,
const dvec3& v2)
289 t.
x() = v1.
y()*v2.
z() - v1.
z()*v2.
y();
290 t.
y() = v1.
z()*v2.
x() - v1.
x()*v2.
z();
291 t.
z() = v1.
x()*v2.
y() - v1.
y()*v2.
x();
295 inline fvec3
min(
const fvec3& a,
const fvec3&
b)
297 return fvec3( a.
x() < b.
x() ? a.
x() : b.
x(),
298 a.
y() < b.
y() ? a.
y() : b.
y(),
299 a.
z() < b.
z() ? a.
z() : b.
z() );
301 inline fvec3
min(
const fvec3& a,
float b)
303 return fvec3( a.
x() < b ? a.
x() :
b,
304 a.
y() < b ? a.
y() :
b,
305 a.
z() < b ? a.
z() :
b );
307 inline dvec3
min(
const dvec3& a,
const dvec3&
b)
309 return dvec3( a.
x() < b.
x() ? a.
x() : b.
x(),
310 a.
y() < b.
y() ? a.
y() : b.
y(),
311 a.
z() < b.
z() ? a.
z() : b.
z() );
313 inline dvec3
min(
const dvec3& a,
double b)
315 return dvec3( a.
x() < b ? a.
x() :
b,
316 a.
y() < b ? a.
y() :
b,
317 a.
z() < b ? a.
z() :
b );
319 inline ivec3
min(
const ivec3& a,
const ivec3&
b)
321 return ivec3( a.
x() < b.
x() ? a.
x() : b.
x(),
322 a.
y() < b.
y() ? a.
y() : b.
y(),
323 a.
z() < b.
z() ? a.
z() : b.
z() );
325 inline ivec3
min(
const ivec3& a,
int b)
327 return ivec3( a.
x() < b ? a.
x() :
b,
328 a.
y() < b ? a.
y() :
b,
329 a.
z() < b ? a.
z() :
b );
331 inline uvec3
min(
const uvec3& a,
const uvec3&
b)
333 return uvec3( a.
x() < b.
x() ? a.
x() : b.
x(),
334 a.
y() < b.
y() ? a.
y() : b.
y(),
335 a.
z() < b.
z() ? a.
z() : b.
z() );
337 inline uvec3
min(
const uvec3& a,
unsigned int b)
339 return uvec3( a.
x() < b ? a.
x() :
b,
340 a.
y() < b ? a.
y() :
b,
341 a.
z() < b ? a.
z() :
b );
343 inline fvec3
max(
const fvec3& a,
const fvec3&
b)
345 return fvec3( a.
x() > b.
x() ? a.
x() : b.
x(),
346 a.
y() > b.
y() ? a.
y() : b.
y(),
347 a.
z() > b.
z() ? a.
z() : b.
z() );
349 inline fvec3
max(
const fvec3& a,
float b)
351 return fvec3( a.
x() > b ? a.
x() :
b,
352 a.
y() > b ? a.
y() :
b,
353 a.
z() > b ? a.
z() :
b );
355 inline dvec3
max(
const dvec3& a,
const dvec3&
b)
357 return dvec3( a.
x() > b.
x() ? a.
x() : b.
x(),
358 a.
y() > b.
y() ? a.
y() : b.
y(),
359 a.
z() > b.
z() ? a.
z() : b.
z() );
361 inline dvec3
max(
const dvec3& a,
double b)
363 return dvec3( a.
x() > b ? a.
x() :
b,
364 a.
y() > b ? a.
y() :
b,
365 a.
z() > b ? a.
z() :
b );
367 inline ivec3
max(
const ivec3& a,
const ivec3&
b)
369 return ivec3( a.
x() > b.
x() ? a.
x() : b.
x(),
370 a.
y() > b.
y() ? a.
y() : b.
y(),
371 a.
z() > b.
z() ? a.
z() : b.
z() );
373 inline ivec3
max(
const ivec3& a,
int b)
375 return ivec3( a.
x() > b ? a.
x() :
b,
376 a.
y() > b ? a.
y() :
b,
377 a.
z() > b ? a.
z() :
b );
379 inline uvec3
max(
const uvec3& a,
const uvec3&
b)
381 return uvec3( a.
x() > b.
x() ? a.
x() : b.
x(),
382 a.
y() > b.
y() ? a.
y() : b.
y(),
383 a.
z() > b.
z() ? a.
z() : b.
z() );
385 inline uvec3
max(
const uvec3& a,
unsigned int b)
387 return uvec3( a.
x() > b ? a.
x() :
b,
388 a.
y() > b ? a.
y() :
b,
389 a.
z() > b ? a.
z() :
b );
391 inline fvec3
clamp(
const fvec3&
x,
float minval,
float maxval) {
return min(
max(x,minval),maxval); }
392 inline fvec3
clamp(
const fvec3&
x,
const fvec3& minval,
const fvec3& maxval) {
return min(
max(x,minval),maxval); }
393 inline ivec3
clamp(
const ivec3&
x,
const ivec3& minval,
const ivec3& maxval) {
return min(
max(x,minval),maxval); }
394 inline dvec3
clamp(
const dvec3&
x,
double minval,
double maxval) {
return min(
max(x,minval),maxval); }
395 inline dvec3
clamp(
const dvec3&
x,
const dvec3& minval,
const dvec3& maxval) {
return min(
max(x,minval),maxval); }
396 inline ivec3
clamp(
const ivec3&
x,
int minval,
int maxval) {
return min(
max(x,minval),maxval); }
397 inline uvec3
clamp(
const uvec3&
x,
unsigned int minval,
unsigned int maxval) {
return min(
max(x,minval),maxval); }
398 inline uvec3
clamp(
const uvec3&
x,
const uvec3& minval,
const uvec3& maxval) {
return min(
max(x,minval),maxval); }
Vector3 & operator=(T_Scalar val)
float clamp(float x, float minval, float maxval)
bool operator==(const Vector3 &other) const
const Vector3 & normalize(T_Scalar *len=NULL)
Vector3(T_Scalar x, T_Scalar y, T_Scalar z)
Vector3< float > fvec3
A 3 components vector with float precision.
const T_Scalar & b() const
Vector3 & operator+=(T_Scalar val)
Vector3 & operator-=(const Vector3 &other)
const T_Scalar & z() const
Vector3 operator*(const Vector3 &other) const
Vector3 & operator*=(T_Scalar val)
bool operator!=(const Vector3 &other) const
Vector3 operator*(T_Scalar val) const
Vector3 operator-() const
Vector3< unsigned char > ubvec3
A 3 components vector with unsigned char precision.
fvec3 cross(const fvec3 &v1, const fvec3 &v2)
T_Scalar mScalar[scalar_count]
const T_Scalar & r() const
Vector3 & operator/=(const Vector3 &other)
Vector3 operator-(const Vector3 &other) const
Vector2< T_Scalar > xy() const
Visualization Library main namespace.
float dot(float a, float b)
Vector3< short > svec3
A 3 components vector with short precision.
Vector3 operator-(T_Scalar val) const
T_Scalar lengthSquared() const
The Vector3 class is a template class that implements a generic 3 components vector, see also vl::fvec3, vl::dvec3, vl::uvec3, vl::ivec3, vl::svec3, vl::usvec3, vl::bvec3, vl::ubvec3.
Vector3 operator/(const Vector3 &other) const
float max(float a, float b)
const T_Scalar & operator[](unsigned i) const
float min(float a, float b)
Vector3 operator/(T_Scalar val) const
Vector3< double > dvec3
A 3 components vector with double precision.
Vector3 operator+(T_Scalar val) const
const T_Scalar & y() const
Vector3< unsigned int > uvec3
A 3 components vector with unsigned int precision.
const T_Scalar & s() const
const T_Scalar & p() const
Vector3< int > ivec3
A 3 components vector with int precision.
Vector3 & operator+=(const Vector3 &other)
The Vector2 class is a template class that implements a generic 2 components vector, see also vl::fvec2, vl::dvec2, vl::uvec2, vl::ivec2, vl::svec2, vl::usvec2, vl::bvec2, vl::ubvec2.
fvec3 vec3
Defined as: 'typedef fvec3 vec3'. See also VL_PIPELINE_PRECISION.
const T_Scalar & t() const
Vector3 & operator=(const Vector3 &other)
Vector3(const Vector3 &other)
bool operator<(const Vector3 &other) const
const T_Scalar & x() const
Vector2< T_Scalar > st() const
const T_Scalar * ptr() const
Vector3(const Vector2< T_Scalar > &v, T_Scalar z)
const T_Scalar & x() const
Vector3 operator+(const Vector3 &other) const
Vector3 & operator-=(T_Scalar val)
Vector3< unsigned short > usvec3
A 3 components vector with unsigned short precision.
T_Scalar & operator[](unsigned i)
Vector3 & operator/=(T_Scalar val)
static const int scalar_count
const T_Scalar & y() const
Vector3< char > bvec3
A 3 components vector with char precision.
const T_Scalar & g() const
Vector3 & operator*=(const Vector3 &other)