library of assembled shared sources

http://lass.cocamware.com

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

4D Vector More...

#include <vector_4d.h>


Data Structures

struct  Rebind

Public Types

enum  { dimension = 4 }
typedef Vector4D< 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

 Vector4D ()
 Vector4D (TParam x, TParam y, TParam z, TParam w)
template<typename U >
 Vector4D (const Vector4D< U > &other)
template<typename U >
 Vector4D (const U &x, const U &y, const U &z, const U &w)
Vector4D::TConstReference operator[] (size_t index) const
Vector4D::TReference operator[] (size_t index)
Vector4D::TConstReference at (signed index) const
 Wrap index around range.
Vector4D::TReference at (signed index)
 Wrap index around range.
const Vector4D< T > & operator+ () const
 A weird way to get back the same object.
const Vector4D< T > operator- () const
Vector4D< T > & operator+= (const Vector4D< T > &other)
 componentwise addition
Vector4D< T > & operator-= (const Vector4D< T > &other)
 componentwise subtraction
Vector4D< T > & operator*= (const Vector4D< T > &other)
 Componentwise multiplication.
Vector4D< T > & operator/= (const Vector4D< T > &other)
 Componentwise division.
Vector4D< T > & operator+= (TParam other)
 add other to each component of this.
Vector4D< T > & operator-= (TParam other)
 subtract other of each component of this.
Vector4D< T > & operator*= (TParam other)
 multiply each component of this with other.
Vector4D< 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 Vector4D< T > normal () const
 return a unit vector with same direction/sense as this vector.
const Vector4D< T > reciprocal () const
const Vector4D< T > project (const Vector4D< T > &other) const
 Project vector on this one.
const Vector4D< T > reject (const Vector4D< T > &other) const
 Project vector on this one.
const Vector4D< T > reflect (const Vector4D< T > &other) const
const Vector4D< T > transform (T(*op)(T)) const
 apply a function to every component
void normalize ()
 Normalize vector.

Data Fields

TValue x
TValue y
TValue z
TValue w

Related Functions

(Note that these are not member functions.)

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


Detailed Description

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

4D Vector

Author:
BdG
Date:
2003

Definition at line 70 of file vector_4d.h.


Member Typedef Documentation

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

Definition at line 72 of file vector_4d.h.

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

Definition at line 74 of file vector_4d.h.

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

Definition at line 75 of file vector_4d.h.

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

Definition at line 76 of file vector_4d.h.

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

Definition at line 77 of file vector_4d.h.

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

Definition at line 78 of file vector_4d.h.


Member Enumeration Documentation

template<typename T >
anonymous enum

Enumerator:
dimension 

Definition at line 80 of file vector_4d.h.


Constructor & Destructor Documentation

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

Definition at line 62 of file vector_4d.inl.

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

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

Definition at line 73 of file vector_4d.inl.

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

Definition at line 85 of file vector_4d.inl.

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

Definition at line 97 of file vector_4d.inl.


Member Function Documentation

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

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

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

Wrap index around range.

Definition at line 128 of file vector_4d.inl.

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

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

Wrap index around range.

Definition at line 138 of file vector_4d.inl.

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

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

A weird way to get back the same object.

Definition at line 148 of file vector_4d.inl.

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

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

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

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

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

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

add other to each component of this.

Definition at line 222 of file vector_4d.inl.

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

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

subtract other of each component of this.

Definition at line 236 of file vector_4d.inl.

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

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

multiply each component of this with other.

Definition at line 250 of file vector_4d.inl.

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

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

divide each component of this by other.

Definition at line 264 of file vector_4d.inl.

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

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

Return true if all the components are (exactly!) zero.

Definition at line 278 of file vector_4d.inl.

References lass::prim::Vector4D< T >::w, lass::prim::Vector4D< T >::x, lass::prim::Vector4D< T >::y, lass::prim::Vector4D< T >::z, and lass::num::NumTraits< C >::zero.

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

Return true if at least one of the components is NaN.

Definition at line 289 of file vector_4d.inl.

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

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

Return squared norm of vector.

Definition at line 299 of file vector_4d.inl.

References lass::prim::Vector4D< T >::dot().

Referenced by lass::prim::Vector4D< T >::norm(), and lass::prim::Vector4D< T >::project().

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

Return norm of vector.

Definition at line 309 of file vector_4d.inl.

References sqrt(), and lass::prim::Vector4D< T >::squaredNorm().

Referenced by lass::prim::Vector4D< T >::normalize().

template<typename T >
const Vector4D< T > lass::prim::Vector4D< 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 323 of file vector_4d.inl.

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

template<typename T >
const Vector4D<T> lass::prim::Vector4D< T >::reciprocal (  )  const

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

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

Project vector on this one.

Definition at line 348 of file vector_4d.inl.

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

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

Definition at line 356 of file vector_4d.inl.

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

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

apply a function to every component

Definition at line 366 of file vector_4d.inl.

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

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

Normalize vector.

Definition at line 376 of file vector_4d.inl.

References lass::prim::Vector4D< T >::norm().

Referenced by lass::prim::Vector4D< T >::normal().


Friends And Related Function Documentation

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

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

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

Definition at line 407 of file vector_4d.inl.

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

componentwise addition

Definition at line 418 of file vector_4d.inl.

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

componentwise subtraction

Definition at line 431 of file vector_4d.inl.

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

Componentwise multiplication.

Definition at line 444 of file vector_4d.inl.

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

Componentwise division.

Definition at line 457 of file vector_4d.inl.

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

add b to all components of a.

Definition at line 470 of file vector_4d.inl.

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

subtract b of all components of a.

Definition at line 483 of file vector_4d.inl.

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

muliply all components of a by b

Definition at line 496 of file vector_4d.inl.

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

divide all components of a by b

Definition at line 509 of file vector_4d.inl.

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

add a to all components of b

Definition at line 522 of file vector_4d.inl.

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

subtract a of all components of b

Definition at line 535 of file vector_4d.inl.

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

multiply all components of b with a

Definition at line 548 of file vector_4d.inl.

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

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

Definition at line 561 of file vector_4d.inl.

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

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

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

Definition at line 573 of file vector_4d.inl.

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

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

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

Definition at line 585 of file vector_4d.inl.

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

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

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

Definition at line 665 of file vector_4d.inl.

References LASS_ENFORCE_STREAM.


Field Documentation

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

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

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

template<typename T >
TValue lass::prim::Vector4D< T >::w


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