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

CTB2vec Class Template Reference

Objectization of a 2-vector. More...

#include <CTB2vec.hxx>

Collaboration diagram for CTB2vec:

Collaboration graph
[legend]
List of all members.

Public Methods

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

Protected Attributes

T m_data [2]

Related Functions

(Note that these are not member functions.)

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

Detailed Description

template<class T>
class CTB2vec< T >

Objectization of a 2-vector.

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

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.

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 CTB2vec.hxx.


Constructor & Destructor Documentation

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

Construct and set all components to 0.

Definition at line 58 of file CTB2vec.icc.

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

Construct with scalar init, set all components to rhs.

Definition at line 68 of file CTB2vec.icc.

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

Construct from 2 values.

Definition at line 77 of file CTB2vec.icc.

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

Copy constructor.

Definition at line 87 of file CTB2vec.icc.


Member Function Documentation

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

Access [0] or x component.

Definition at line 96 of file CTB2vec.icc.

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

Constant access [0] or x component.

Definition at line 105 of file CTB2vec.icc.

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

Access [1] or y component.

Definition at line 114 of file CTB2vec.icc.

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

Constant access [1] or y component.

Definition at line 123 of file CTB2vec.icc.

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

Set [0] or x component.

Definition at line 132 of file CTB2vec.icc.

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

Set [1] or y component.

Definition at line 141 of file CTB2vec.icc.

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

Returns length of vector.

Definition at line 151 of file CTB2vec.icc.

Referenced by CTBabs().

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

Returns inner product with rhs.

Definition at line 160 of file CTB2vec.icc.

Referenced by Project().

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

Returns projection of vector onto vectors x and y.

Definition at line 170 of file CTB2vec.icc.

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

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

Definition at line 180 of file CTB2vec.icc.

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

Access element.

Definition at line 191 of file CTB2vec.icc.

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

Constant access element.

Definition at line 200 of file CTB2vec.icc.

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

Convert to pointer.

Definition at line 209 of file CTB2vec.icc.

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

Constant convert to pointer.

Definition at line 218 of file CTB2vec.icc.

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

Returns negative of vector.

Definition at line 227 of file CTB2vec.icc.

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

Add vector rhs.

Definition at line 236 of file CTB2vec.icc.

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

Subtract vector rhs.

Definition at line 247 of file CTB2vec.icc.

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

Multiply each component by the scalar value rhs.

Definition at line 258 of file CTB2vec.icc.

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

Divide each component by the scalar value rhs.

Definition at line 269 of file CTB2vec.icc.

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

Set all components to the scalar value rhs.

Definition at line 281 of file CTB2vec.icc.

Referenced by CTB2vec().

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

Copy values of vector rhs.

Definition at line 292 of file CTB2vec.icc.


Friends And Related Function Documentation

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

Returns sum of two vectors lhs and rhs .

Definition at line 306 of file CTB2vec.icc.

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

Returns sum of vectors lhs and scalar f_rhs .

Definition at line 318 of file CTB2vec.icc.

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

Returns sum of scaler f_lhs and vector rhs .

Definition at line 330 of file CTB2vec.icc.

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

Returns difference of two vectors lhs and rhs .

Definition at line 342 of file CTB2vec.icc.

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

Returns difference of vectors lhs and scalar f_rhs .

Definition at line 354 of file CTB2vec.icc.

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

Returns difference of scaler f_lhs and vector rhs .

Definition at line 366 of file CTB2vec.icc.

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

Returns scalar product of two vectors lhs and rhs .

Definition at line 378 of file CTB2vec.icc.

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

Returns vector lhs and multiplyied by scalar f_rhs .

Definition at line 390 of file CTB2vec.icc.

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

Returns vector rhs and multiplyied by scalar f_lhs .

Definition at line 402 of file CTB2vec.icc.

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

Returns vector lhs and divided by scalar f_rhs .

Definition at line 414 of file CTB2vec.icc.

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

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

Definition at line 426 of file CTB2vec.icc.

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

true if vector lhs equals scalar f_rhs in each component.

Definition at line 438 of file CTB2vec.icc.

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

true if vector rhs equals scalar f_lhs in each component.

Definition at line 450 of file CTB2vec.icc.

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

ostream insertion.

Definition at line 462 of file CTB2vec.icc.

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

Returns length of vector vec .

Definition at line 478 of file CTB2vec.icc.


Member Data Documentation

template<class T>
T CTB2vec::m_data[2] [protected]
 

data vector.

Definition at line 60 of file CTB2vec.hxx.


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