library of assembled shared sources

http://lass.cocamware.com

lass::prim::Vector3D< T > Struct Template Reference

3D Vector More...

#include <vector_3d.h>


Data Structures

struct  Rebind

Public Types

enum  { dimension = 3 }
typedef Vector3D< T > TSelf
typedef util::CallTraits< T >
::TValue 
TValue
typedef util::CallTraits< T >
::TParam 
TParam
typedef util::CallTraits< T >
::TReference 
TReference
typedef util::CallTraits< T >
::TConstReference 
TConstReference
typedef num::NumTraits< T > TNumTraits

Public Member Functions

 Vector3D ()
 Vector3D (TParam x, TParam y, TParam z)
template<typename U >
 Vector3D (const Vector3D< U > &other)
template<typename U >
 Vector3D (const U &x, const U &y, const U &z)
Vector3D::TConstReference operator[] (size_t index) const
Vector3D::TReference operator[] (size_t index)
Vector3D::TConstReference at (signed index) const
 Wrap index around range.
Vector3D::TReference at (signed index)
 Wrap index around range.
const Vector3D< T > & operator+ () const
 A weird way to get back the same object.
const Vector3D< T > operator- () const
Vector3D< T > & operator+= (const Vector3D< T > &other)
 componentwise addition
Vector3D< T > & operator-= (const Vector3D< T > &other)
 componentwise subtraction
Vector3D< T > & operator*= (const Vector3D< T > &other)
 Componentwise multiplication.
Vector3D< T > & operator/= (const Vector3D< T > &other)
 Componentwise division.
Vector3D< T > & operator+= (TParam other)
 add other to each component of this.
Vector3D< T > & operator-= (TParam other)
 subtract other of each component of this.
Vector3D< T > & operator*= (TParam other)
 multiply each component of this with other.
Vector3D< T > & operator/= (TParam other)
 divide each component of this by other.
const bool isZero () const
 Return true if all the components are (exactly!) zero.
const bool isNaN () const
 Return true if at least one of the components is NaN.
const TValue squaredNorm () const
 Return squared norm of vector.
const TValue norm () const
 Return norm of vector.
const Vector3D< T > normal () const
 return a unit vector with same direction/sense as this vector.
const Vector3D< T > reciprocal () const
 return the reciprocal version of this vector
const Vector3D< T > project (const Vector3D< T > &other) const
 Project vector on this one.
const Vector3D< T > reject (const Vector3D< T > &other) const
 Reject vector from this one.
const Vector3D< T > reflect (const Vector3D< T > &other) const
const Vector3D< T > transform (T(*op)(T)) const
 apply a function to every component
void normalize ()
 Normalize vector.

Static Public Member Functions

template<class RandomGenerator >
static Vector3D< T > random (RandomGenerator &generator)
 Random unit vector.

Data Fields

TValue x
TValue y
TValue z

Related Functions

(Note that these are not member functions.)

template<typename T >
Vector3D< T >::TValue dot (const Vector3D< T > &a, const Vector3D< T > &b)
 dot product.
template<typename T >
Vector3D< T > cross (const Vector3D< T > &a, const Vector3D< T > &b)
 cross product
template<typename T >
bool operator== (const Vector3D< T > &a, const Vector3D< T > &b)
template<typename T >
bool operator!= (const Vector3D< T > &a, const Vector3D< T > &b)
template<typename T >
Vector3D< T > operator+ (const Vector3D< T > &a, const Vector3D< T > &b)
 componentwise addition
template<typename T >
Vector3D< T > operator- (const Vector3D< T > &a, const Vector3D< T > &b)
 componentwise subtraction
template<typename T >
Vector3D< T > operator* (const Vector3D< T > &a, const Vector3D< T > &b)
 Componentwise multiplication.
template<typename T >
Vector3D< T > operator/ (const Vector3D< T > &a, const Vector3D< T > &b)
 Componentwise division.
template<typename T >
Vector3D< T > operator+ (const Vector3D< T > &a, typename Vector3D< T >::TParam b)
 add b to all components of a.
template<typename T >
Vector3D< T > operator- (const Vector3D< T > &a, typename Vector3D< T >::TParam b)
 subtract b of all components of a.
template<typename T >
Vector3D< T > operator* (const Vector3D< T > &a, typename Vector3D< T >::TParam b)
 muliply all components of a by b
template<typename T >
Vector3D< T > operator/ (const Vector3D< T > &a, typename Vector3D< T >::TParam b)
 divide all components of a by b
template<typename T >
Vector3D< T > operator+ (typename Vector3D< T >::TParam a, const Vector3D< T > &b)
 add a to all components of b
template<typename T >
Vector3D< T > operator- (typename Vector3D< T >::TParam a, const Vector3D< T > &b)
 subtract a of all components of b
template<typename T >
Vector3D< T > operator* (typename Vector3D< T >::TParam a, const Vector3D< T > &b)
 multiply all components of b with a
template<typename T >
Vector3D< T > pointwiseMin (const Vector3D< T > &a, const Vector3D< T > &b)
 return a vector with, for each coordinate, the minimum value of a and b
template<typename T >
Vector3D< T > pointwiseMax (const Vector3D< T > &a, const Vector3D< T > &b)
 return a vector with, for each coordinate, the maximum value of a and b
template<typename T >
Vector3D< T > lerp (const Vector3D< T > &a, const Vector3D< T > &b, typename Vector3D< T >::TParam t)
 interpolate linearly between two vectors: a + t * (b - a)
template<typename T , typename Char , typename Traits >
std::basic_ostream< Char,
Traits > & 
operator<< (std::basic_ostream< Char, Traits > &stream, const Vector3D< T > &b)
template<typename T , typename Char , typename Traits >
std::basic_istream< Char,
Traits > & 
operator>> (std::basic_istream< Char, Traits > &stream, Vector3D< T > &b)
template<typename T >
io::XmlOStreamoperator<< (io::XmlOStream &stream, const Vector3D< T > &b)


Detailed Description

template<typename T>
struct lass::prim::Vector3D< T >

3D Vector

Author:
BdG
Date:
2003

Definition at line 71 of file vector_3d.h.


Member Typedef Documentation

template<typename T >
typedef Vector3D<T> lass::prim::Vector3D< T >::TSelf

Definition at line 73 of file vector_3d.h.

template<typename T >
typedef util::CallTraits<T>::TValue lass::prim::Vector3D< T >::TValue

Definition at line 75 of file vector_3d.h.

template<typename T >
typedef util::CallTraits<T>::TParam lass::prim::Vector3D< T >::TParam

Definition at line 76 of file vector_3d.h.

template<typename T >
typedef util::CallTraits<T>::TReference lass::prim::Vector3D< T >::TReference

Definition at line 77 of file vector_3d.h.

template<typename T >
typedef util::CallTraits<T>::TConstReference lass::prim::Vector3D< T >::TConstReference

Definition at line 78 of file vector_3d.h.

template<typename T >
typedef num::NumTraits<T> lass::prim::Vector3D< T >::TNumTraits

Definition at line 79 of file vector_3d.h.


Member Enumeration Documentation

template<typename T >
anonymous enum

Enumerator:
dimension 

Definition at line 81 of file vector_3d.h.


Constructor & Destructor Documentation

template<typename T >
lass::prim::Vector3D< T >::Vector3D (  )  [inline]

Definition at line 65 of file vector_3d.inl.

Referenced by lass::prim::Vector3D< T >::operator-().

template<typename T >
lass::prim::Vector3D< T >::Vector3D ( TParam  x,
TParam  y,
TParam  z 
) [inline]

Definition at line 75 of file vector_3d.inl.

template<typename T >
template<typename U >
lass::prim::Vector3D< T >::Vector3D ( const Vector3D< U > &  other  )  [inline, explicit]

Definition at line 86 of file vector_3d.inl.

template<typename T >
template<typename U >
lass::prim::Vector3D< T >::Vector3D ( const U &  x,
const U &  y,
const U &  z 
) [inline]

Definition at line 97 of file vector_3d.inl.


Member Function Documentation

template<typename T >
Vector3D< T >::TConstReference lass::prim::Vector3D< T >::operator[] ( size_t  index  )  const [inline]

template<typename T >
Vector3D< T >::TReference lass::prim::Vector3D< T >::operator[] ( size_t  index  )  [inline]

template<typename T >
Vector3D< T >::TConstReference lass::prim::Vector3D< T >::at ( signed  index  )  const [inline]

Wrap index around range.

Definition at line 127 of file vector_3d.inl.

References lass::prim::Vector3D< T >::dimension, lass::num::mod(), and lass::prim::Vector3D< T >::x.

template<typename T >
Vector3D< T >::TReference lass::prim::Vector3D< T >::at ( signed  index  )  [inline]

Wrap index around range.

Definition at line 137 of file vector_3d.inl.

References lass::prim::Vector3D< T >::dimension, lass::num::mod(), and lass::prim::Vector3D< T >::x.

template<typename T >
const Vector3D< T > & lass::prim::Vector3D< T >::operator+ (  )  const [inline]

A weird way to get back the same object.

Definition at line 147 of file vector_3d.inl.

template<typename T >
const Vector3D< T > lass::prim::Vector3D< T >::operator- (  )  const [inline]

template<typename T >
Vector3D< T > & lass::prim::Vector3D< T >::operator+= ( const Vector3D< T > &  other  )  [inline]

componentwise addition

Definition at line 165 of file vector_3d.inl.

References lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

template<typename T >
Vector3D< T > & lass::prim::Vector3D< T >::operator-= ( const Vector3D< T > &  other  )  [inline]

componentwise subtraction

Definition at line 178 of file vector_3d.inl.

References lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

template<typename T >
Vector3D< T > & lass::prim::Vector3D< T >::operator*= ( const Vector3D< T > &  other  )  [inline]

Componentwise multiplication.

Definition at line 191 of file vector_3d.inl.

References lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

template<typename T >
Vector3D< T > & lass::prim::Vector3D< T >::operator/= ( const Vector3D< T > &  other  )  [inline]

Componentwise division.

Definition at line 204 of file vector_3d.inl.

References lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

template<typename T >
Vector3D< T > & lass::prim::Vector3D< T >::operator+= ( TParam  other  )  [inline]

add other to each component of this.

Definition at line 217 of file vector_3d.inl.

References lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

template<typename T >
Vector3D< T > & lass::prim::Vector3D< T >::operator-= ( TParam  other  )  [inline]

subtract other of each component of this.

Definition at line 230 of file vector_3d.inl.

References lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

template<typename T >
Vector3D< T > & lass::prim::Vector3D< T >::operator*= ( TParam  other  )  [inline]

multiply each component of this with other.

Definition at line 243 of file vector_3d.inl.

References lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

template<typename T >
Vector3D< T > & lass::prim::Vector3D< T >::operator/= ( TParam  other  )  [inline]

divide each component of this by other.

Definition at line 256 of file vector_3d.inl.

References lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

template<typename T >
const bool lass::prim::Vector3D< T >::isZero (  )  const [inline]

template<typename T >
const bool lass::prim::Vector3D< T >::isNaN (  )  const [inline]

template<typename T >
const Vector3D< T >::TValue lass::prim::Vector3D< T >::squaredNorm (  )  const [inline]

template<typename T >
const Vector3D< T >::TValue lass::prim::Vector3D< T >::norm (  )  const [inline]

template<typename T >
const Vector3D< T > lass::prim::Vector3D< T >::normal (  )  const [inline]

return a unit vector with same direction/sense as this vector.

The normalized vector of X is a vector in the same direction but with norm (length) 1. It is denoted X^ and given by X^ = X / |X|, http://mathworld.wolfram.com/NormalizedVector.html.

Definition at line 313 of file vector_3d.inl.

References lass::prim::Vector3D< T >::normalize().

Referenced by lass::prim::Transformation3D< T >::rotation(), lass::prim::SimplePolygon3D< T, PlaneEquationPolicy, PlaneNormalizingPolicy >::signedArea(), and lass::prim::SimplePolygon3D< T, PlaneEquationPolicy, PlaneNormalizingPolicy >::surfaceCentroid().

template<typename T >
const Vector3D< T > lass::prim::Vector3D< T >::reciprocal (  )  const [inline]

return the reciprocal version of this vector

Definition at line 325 of file vector_3d.inl.

References lass::num::NumTraits< C >::one.

template<typename T >
const Vector3D< T > lass::prim::Vector3D< T >::project ( const Vector3D< T > &  other  )  const [inline]

template<typename T >
const Vector3D< T > lass::prim::Vector3D< T >::reject ( const Vector3D< T > &  other  )  const [inline]

Reject vector from this one.

Definition at line 350 of file vector_3d.inl.

References lass::prim::Vector3D< T >::project().

template<typename T >
const Vector3D< T > lass::prim::Vector3D< T >::reflect ( const Vector3D< T > &  other  )  const [inline]

Definition at line 358 of file vector_3d.inl.

References lass::prim::Vector3D< T >::project().

template<typename T >
const Vector3D< T > lass::prim::Vector3D< T >::transform ( T(*)(T)  op  )  const [inline]

template<typename T >
void lass::prim::Vector3D< T >::normalize (  )  [inline]

template<typename T >
template<class RandomGenerator >
Vector3D< T > lass::prim::Vector3D< T >::random ( RandomGenerator &  generator  )  [inline, static]


Friends And Related Function Documentation

template<typename T >
Vector3D< T >::TValue dot ( const Vector3D< T > &  a,
const Vector3D< T > &  b 
) [related]

template<typename T >
Vector3D< T > cross ( const Vector3D< T > &  a,
const Vector3D< T > &  b 
) [related]

template<typename T >
bool operator== ( const Vector3D< T > &  a,
const Vector3D< T > &  b 
) [related]

template<typename T >
bool operator!= ( const Vector3D< T > &  a,
const Vector3D< T > &  b 
) [related]

Definition at line 442 of file vector_3d.inl.

template<typename T >
Vector3D< T > operator+ ( const Vector3D< T > &  a,
const Vector3D< T > &  b 
) [related]

componentwise addition

Definition at line 453 of file vector_3d.inl.

template<typename T >
Vector3D< T > operator- ( const Vector3D< T > &  a,
const Vector3D< T > &  b 
) [related]

componentwise subtraction

Definition at line 466 of file vector_3d.inl.

template<typename T >
Vector3D< T > operator* ( const Vector3D< T > &  a,
const Vector3D< T > &  b 
) [related]

Componentwise multiplication.

Definition at line 479 of file vector_3d.inl.

template<typename T >
Vector3D< T > operator/ ( const Vector3D< T > &  a,
const Vector3D< T > &  b 
) [related]

Componentwise division.

Definition at line 492 of file vector_3d.inl.

template<typename T >
Vector3D< T > operator+ ( const Vector3D< T > &  a,
typename Vector3D< T >::TParam  b 
) [related]

add b to all components of a.

Definition at line 505 of file vector_3d.inl.

template<typename T >
Vector3D< T > operator- ( const Vector3D< T > &  a,
typename Vector3D< T >::TParam  b 
) [related]

subtract b of all components of a.

Definition at line 518 of file vector_3d.inl.

template<typename T >
Vector3D< T > operator* ( const Vector3D< T > &  a,
typename Vector3D< T >::TParam  b 
) [related]

muliply all components of a by b

Definition at line 531 of file vector_3d.inl.

template<typename T >
Vector3D< T > operator/ ( const Vector3D< T > &  a,
typename Vector3D< T >::TParam  b 
) [related]

divide all components of a by b

Definition at line 544 of file vector_3d.inl.

template<typename T >
Vector3D< T > operator+ ( typename Vector3D< T >::TParam  a,
const Vector3D< T > &  b 
) [related]

add a to all components of b

Definition at line 557 of file vector_3d.inl.

template<typename T >
Vector3D< T > operator- ( typename Vector3D< T >::TParam  a,
const Vector3D< T > &  b 
) [related]

subtract a of all components of b

Definition at line 570 of file vector_3d.inl.

template<typename T >
Vector3D< T > operator* ( typename Vector3D< T >::TParam  a,
const Vector3D< T > &  b 
) [related]

multiply all components of b with a

Definition at line 583 of file vector_3d.inl.

template<typename T >
Vector3D< T > pointwiseMin ( const Vector3D< T > &  a,
const Vector3D< T > &  b 
) [related]

return a vector with, for each coordinate, the minimum value of a and b

Definition at line 596 of file vector_3d.inl.

References lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

template<typename T >
Vector3D< T > pointwiseMax ( const Vector3D< T > &  a,
const Vector3D< T > &  b 
) [related]

return a vector with, for each coordinate, the maximum value of a and b

Definition at line 607 of file vector_3d.inl.

References lass::prim::Vector3D< T >::x, lass::prim::Vector3D< T >::y, and lass::prim::Vector3D< T >::z.

template<typename T >
Vector3D< T > lerp ( const Vector3D< T > &  a,
const Vector3D< T > &  b,
typename Vector3D< T >::TParam  t 
) [related]

interpolate linearly between two vectors: a + t * (b - a)

Definition at line 618 of file vector_3d.inl.

template<typename T , typename Char , typename Traits >
std::basic_ostream< Char, Traits > & operator<< ( std::basic_ostream< Char, Traits > &  stream,
const Vector3D< T > &  b 
) [related]

template<typename T , typename Char , typename Traits >
std::basic_istream< Char, Traits > & operator>> ( std::basic_istream< Char, Traits > &  stream,
Vector3D< T > &  b 
) [related]

template<typename T >
io::XmlOStream & operator<< ( io::XmlOStream stream,
const Vector3D< T > &  b 
) [related]

Definition at line 690 of file vector_3d.inl.

References LASS_ENFORCE_STREAM.


Field Documentation

template<typename T >
TValue lass::prim::Vector3D< T >::x

Definition at line 91 of file vector_3d.h.

Referenced by lass::prim::Aabb3D< T, MinMaxPolicy >::area(), lass::prim::Vector3D< T >::at(), lass::prim::SimplePolygon3D< T, PlaneEquationPolicy, PlaneNormalizingPolicy >::clip(), lass::prim::Aabb3D< T, MinMaxPolicy >::collides(), lass::prim::Vector3D< T >::cross(), lass::prim::Vector3D< T >::dot(), lass::prim::impl::Plane3DImplDetail::generateDirections(), lass::prim::TriangleMesh3D< T, BoundingVolumeHierarchy, SplitHeuristics >::Triangle::intersect(), lass::prim::Aabb3D< T, MinMaxPolicy >::intersects(), lass::prim::Vector3D< T >::isNaN(), lass::prim::Vector3D< T >::isZero(), lass::prim::Plane3D< T, EquationPolicy, NormalizingPolicy >::majorAxis(), lass::prim::Transformation3D< T >::normalTransform(), lass::prim::Vector3D< T >::operator*=(), lass::prim::Vector3D< T >::operator+=(), lass::prim::Vector3D< T >::operator-(), lass::prim::Vector3D< T >::operator-=(), lass::prim::Vector3D< T >::operator/=(), lass::prim::Vector3D< T >::operator<<(), lass::prim::Vector3D< T >::operator==(), lass::prim::Vector3D< T >::operator>>(), lass::prim::Vector3D< T >::operator[](), lass::prim::Vector3D< T >::pointwiseMax(), lass::prim::Vector3D< T >::pointwiseMin(), lass::prim::Transformation3D< T >::rotation(), lass::prim::Transformation3D< T >::scaler(), lass::prim::Vector3D< T >::transform(), lass::prim::Transformation3D< T >::transform(), lass::prim::Transformation3D< T >::Transformation3D(), lass::prim::Transformation3D< T >::translation(), and lass::prim::Aabb3D< T, MinMaxPolicy >::volume().

template<typename T >
TValue lass::prim::Vector3D< T >::y

template<typename T >
TValue lass::prim::Vector3D< T >::z


The documentation for this struct was generated from the following files:

Generated on Mon Nov 10 14:22:14 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo