Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

CTB3vec Class Template Reference

Objectization of a 3-vector. More...

#include <CTB3vec.hxx>

Collaboration diagram for CTB3vec:

Collaboration graph
[legend]
List of all members.

Public Methods

 CTB3vec ()
 CTB3vec (T rhs)
 CTB3vec (T x, T y, T z)
 CTB3vec (const CTB3vec< T > &rhs)
TX ()
const TX () const
TY ()
const TY () const
TZ ()
const TZ () const
void X (T x)
void Y (T y)
void Z (T z)
T Length () const
T Dot (const CTB3vec< T > &rhs) const
CTB3vec< TCross (const CTB3vec< T > &rhs) const
CTB3vec< TProject (const CTB3vec< T > &x, const CTB3vec< T > &y, const CTB3vec< T > &z) const
CTB3vec< TUnProject (const CTB3vec< T > &x, const CTB3vec< T > &y, const CTB3vec< T > &z) const
Toperator[] (CTBint i_ind)
const Toperator[] (CTBint i_ind) const
 operator T * ()
 operator const T * () const
CTB3vec< Toperator- () const
CTB3vec< T > & operator+= (const CTB3vec< T > &rhs)
CTB3vec< T > & operator-= (const CTB3vec< T > &rhs)
CTB3vec< T > & operator *= (T rhs)
CTB3vec< T > & operator/= (T rhs)
CTB3vec< T > & operator= (T rhs)
CTB3vec< T > & operator= (const CTB3vec< T > &rhs)

Protected Attributes

T m_data [3]

Related Functions

(Note that these are not member functions.)

CTB3vec< Toperator+ (const CTB3vec< T > &lhs, const CTB3vec< T > &rhs)
CTB3vec< Toperator+ (const CTB3vec< T > &lhs, T f_rhs)
CTB3vec< Toperator+ (T f_lhs, const CTB3vec< T > &rhs)
CTB3vec< Toperator- (const CTB3vec< T > &lhs, const CTB3vec< T > &rhs)
CTB3vec< Toperator- (const CTB3vec< T > &lhs, T f_rhs)
CTB3vec< Toperator- (T f_lhs, const CTB3vec< T > &rhs)
T operator * (const CTB3vec< T > &lhs, const CTB3vec< T > &rhs)
CTB3vec< Toperator * (const CTB3vec< T > &lhs, T f_rhs)
CTB3vec< Toperator * (T f_lhs, const CTB3vec< T > &rhs)
CTB3vec< Toperator/ (const CTB3vec< T > &lhs, T f_rhs)
bool operator== (const CTB3vec< T > &lhs, const CTB3vec< T > &rhs)
bool operator== (const CTB3vec< T > &lhs, T f_rhs)
bool operator== (T f_lhs, const CTB3vec< T > &rhs)
ostream & operator<< (ostream &os, const CTB3vec< T > &obj)
T CTBabs (const CTB3vec< T > &vec)

Detailed Description

template<class T>
class CTB3vec< T >

Objectization of a 3-vector.

The template class CTB3vec represents a 3 component vector of type T. It is mainly intended for usage in 3d geometry, the components are thus called X, Y and Z.

The 3 components can be accessed (both read and write) either through the index operator\c operator[]() or via the X(), Y() , Z() methods, so v[0] and v.X() is equivalent.

Note, that this class is intended to be used with arithmetic data types, like float or double. It is expected that the arithmetic operators are defined and that an object of type T can be initialized and assigned with a 0.

All basic vector algebra operations for 3-vectors are defined, especially

In addition various operations between vector and scalar quantities are defined

If scalars and vectors are mixed the scalar must have exactly the same data type, there is no type promotion or conversion of the scalar. This requires often an explicit cast or type suffix.

Implementation note:
All scalar values in argument lists are passed by value and not, as in most other template classes, by reference. Some if not most compilers inhibit optimizations when the address of a variable is taken, and some treat passing a variable by reference even to an inline functions as taking the address of that variable. Since this class is mainly instanciated for elementary data types like double, there is no performance penalty for passing arguments by value, but due to potentially better optimization, even a performance advantage.
Requirements:

Definition at line 17 of file CTB3vec.hxx.


Constructor & Destructor Documentation

template<class T>
CTB3vec< T >::CTB3vec [inline]
 

Construct and set all components to 0.

Definition at line 74 of file CTB3vec.icc.

template<class T>
CTB3vec< T >::CTB3vec T rhs [inline, explicit]
 

Construct with scalar init, set all components to rhs.

Definition at line 85 of file CTB3vec.icc.

template<class T>
CTB3vec< T >::CTB3vec T x,
T y,
T z
[inline]
 

Construct from 3 values.

Definition at line 94 of file CTB3vec.icc.

template<class T>
CTB3vec< T >::CTB3vec const CTB3vec< T > & rhs [inline]
 

Copy constructor.

Definition at line 105 of file CTB3vec.icc.


Member Function Documentation

template<class T>
T & CTB3vec< T >::X [inline]
 

Access [0] or x component.

Definition at line 114 of file CTB3vec.icc.

Referenced by Cross().

template<class T>
const T & CTB3vec< T >::X const [inline]
 

Constant access [0] or x component.

Definition at line 123 of file CTB3vec.icc.

template<class T>
T & CTB3vec< T >::Y [inline]
 

Access [1] or y component.

Definition at line 132 of file CTB3vec.icc.

Referenced by Cross().

template<class T>
const T & CTB3vec< T >::Y const [inline]
 

Constant access [1] or y component.

Definition at line 141 of file CTB3vec.icc.

template<class T>
T & CTB3vec< T >::Z [inline]
 

Access [2] or z component.

Definition at line 150 of file CTB3vec.icc.

Referenced by Cross().

template<class T>
const T & CTB3vec< T >::Z const [inline]
 

Constant access [2] or z component.

Definition at line 159 of file CTB3vec.icc.

template<class T>
void CTB3vec< T >::X T x [inline]
 

Set [0] or x component.

Definition at line 168 of file CTB3vec.icc.

template<class T>
void CTB3vec< T >::Y T y [inline]
 

Set [1] or y component.

Definition at line 178 of file CTB3vec.icc.

template<class T>
void CTB3vec< T >::Z T z [inline]
 

Set [2] or z component.

Definition at line 188 of file CTB3vec.icc.

template<class T>
T CTB3vec< T >::Length const [inline]
 

Returns length of vector.

Definition at line 198 of file CTB3vec.icc.

Referenced by CTBabs().

template<class T>
T CTB3vec< T >::Dot const CTB3vec< T > & rhs const [inline]
 

Returns scalar (aka inner or dot) product with rhs.

Definition at line 207 of file CTB3vec.icc.

Referenced by Project().

template<class T>
CTB3vec< T > CTB3vec< T >::Cross const CTB3vec< T > & rhs const [inline]
 

Returns vector (aka cross) product with rhs.

Definition at line 218 of file CTB3vec.icc.

template<class T>
CTB3vec< T > CTB3vec< T >::Project const CTB3vec< T > & x,
const CTB3vec< T > & y,
const CTB3vec< T > & z
const [inline]
 

Returns projection of vector onto vectors x, y and z.

Definition at line 229 of file CTB3vec.icc.

template<class T>
CTB3vec< T > CTB3vec< T >::UnProject const CTB3vec< T > & x,
const CTB3vec< T > & y,
const CTB3vec< T > & z
const [inline]
 

Returns vector with components [0] * x, [1] * y and [2] * z.

Definition at line 240 of file CTB3vec.icc.

template<class T>
T & CTB3vec< T >::operator[] CTBint i_ind [inline]
 

Access element.

Definition at line 253 of file CTB3vec.icc.

template<class T>
const T & CTB3vec< T >::operator[] CTBint i_ind const [inline]
 

Constant access element.

Definition at line 262 of file CTB3vec.icc.

template<class T>
CTB3vec< T >::operator T * [inline]
 

Convert to pointer.

Definition at line 271 of file CTB3vec.icc.

template<class T>
CTB3vec< T >::operator const T * const [inline]
 

Constant convert to pointer.

Definition at line 280 of file CTB3vec.icc.

template<class T>
CTB3vec< T > CTB3vec< T >::operator- const [inline]
 

Returns negative of vector.

Definition at line 289 of file CTB3vec.icc.

template<class T>
CTB3vec< T > & CTB3vec< T >::operator+= const CTB3vec< T > & rhs [inline]
 

Add vector rhs.

Definition at line 298 of file CTB3vec.icc.

template<class T>
CTB3vec< T > & CTB3vec< T >::operator-= const CTB3vec< T > & rhs [inline]
 

Subtract vector rhs.

Definition at line 310 of file CTB3vec.icc.

template<class T>
CTB3vec< T > & CTB3vec< T >::operator *= T rhs [inline]
 

Multiply each component by the scalar value rhs.

Definition at line 322 of file CTB3vec.icc.

template<class T>
CTB3vec< T > & CTB3vec< T >::operator/= T rhs [inline]
 

Divide each component by the scalar value rhs.

Definition at line 334 of file CTB3vec.icc.

template<class T>
CTB3vec< T > & CTB3vec< T >::operator= T rhs [inline]
 

Set all components to the scalar value rhs.

Definition at line 347 of file CTB3vec.icc.

Referenced by CTB3vec().

template<class T>
CTB3vec< T > & CTB3vec< T >::operator= const CTB3vec< T > & rhs [inline]
 

Copy values of vector rhs.

Definition at line 359 of file CTB3vec.icc.


Friends And Related Function Documentation

template<class T>
CTB3vec< T > operator+ const CTB3vec< T > & lhs,
const CTB3vec< T > & rhs
[related]
 

Returns sum of two vectors lhs and rhs .

Definition at line 374 of file CTB3vec.icc.

template<class T>
CTB3vec< T > operator+ const CTB3vec< T > & lhs,
T f_rhs
[related]
 

Returns sum of vectors lhs and scalar f_rhs .

Definition at line 386 of file CTB3vec.icc.

template<class T>
CTB3vec< T > operator+ T f_lhs,
const CTB3vec< T > & rhs
[related]
 

Returns sum of scaler f_lhs and vector rhs .

Definition at line 398 of file CTB3vec.icc.

template<class T>
CTB3vec< T > operator- const CTB3vec< T > & lhs,
const CTB3vec< T > & rhs
[related]
 

Returns difference of two vectors lhs and rhs .

Definition at line 410 of file CTB3vec.icc.

template<class T>
CTB3vec< T > operator- const CTB3vec< T > & lhs,
T f_rhs
[related]
 

Returns difference of vectors lhs and scalar f_rhs .

Definition at line 422 of file CTB3vec.icc.

template<class T>
CTB3vec< T > operator- T f_lhs,
const CTB3vec< T > & rhs
[related]
 

Returns difference of scaler f_lhs and vector rhs .

Definition at line 434 of file CTB3vec.icc.

template<class T>
T operator * const CTB3vec< T > & lhs,
const CTB3vec< T > & rhs
[related]
 

Returns scalar (aka inner) product of two vectors lhs and rhs .

Definition at line 446 of file CTB3vec.icc.

template<class T>
CTB3vec< T > operator * const CTB3vec< T > & lhs,
T f_rhs
[related]
 

Returns vector lhs and multiplyied by scalar f_rhs .

Definition at line 458 of file CTB3vec.icc.

template<class T>
CTB3vec< T > operator * T f_lhs,
const CTB3vec< T > & rhs
[related]
 

Returns vector rhs and multiplyied by scalar f_lhs .

Definition at line 470 of file CTB3vec.icc.

template<class T>
CTB3vec< T > operator/ const CTB3vec< T > & lhs,
T f_rhs
[related]
 

Returns vector lhs and divided by scalar f_rhs .

Definition at line 482 of file CTB3vec.icc.

template<class T>
bool operator== const CTB3vec< T > & lhs,
const CTB3vec< T > & rhs
[related]
 

Returns true if all components of lhs are equal to rhs.

Definition at line 494 of file CTB3vec.icc.

template<class T>
bool operator== const CTB3vec< T > & lhs,
T f_rhs
[related]
 

true if vector lhs equals scalar f_rhs in each component.

Definition at line 506 of file CTB3vec.icc.

template<class T>
bool operator== T f_lhs,
const CTB3vec< T > & rhs
[related]
 

true if vector rhs equals scalar f_lhs in each component.

Definition at line 518 of file CTB3vec.icc.

template<class T>
ostream & operator<< ostream & os,
const CTB3vec< T > & obj
[related]
 

ostream insertion.

Definition at line 530 of file CTB3vec.icc.

template<class T>
T CTBabs const CTB3vec< T > & vec [related]
 

Returns length of vector vec .

Definition at line 547 of file CTB3vec.icc.


Member Data Documentation

template<class T>
T CTB3vec::m_data[3] [protected]
 

data vector.

Definition at line 67 of file CTB3vec.hxx.


The documentation for this class was generated from the following files:
Generated at Fri Oct 24 18:13:08 2003 for CTBbase by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001