#include <vector.h>
Public Member Functions | |
~TVector () | |
Destructor. | |
void | SetN (uint N) |
Size change. | |
T & | operator() (uint i) |
Reference operator. | |
T * | GetAnsiRef () |
ANSI (C/C++ array) reference. | |
uint | GetN () |
Vector's cardinality. | |
int | GetType () |
Vector's type (ROW_VECTOR/COL_VECTOR). | |
T | GetNorm () |
Mathematical norm (L2). | |
void | Normalize () |
Normalizes the vector. | |
T | Dot (const TVector< T > &r) |
Dot product. | |
| |
T * | _vector |
Vector's internal state. | |
uint | _N |
Cardinality. | |
int | _type |
Type (ROW_VECTOR/COL_VECTOR). | |
bool | _myMemory |
Have I created _vector? | |
TVector (uint N=3, T data=(T) 0, int type=0x02) | |
Default constructor. | |
TVector (const TVector< T > &r) | |
Copy constructor. | |
TVector (T *block, uint N, bool copy=true, int type=0x02) | |
Use this to treat an ANSI array as a TVector. | |
TVector< T > & | operator= (const TVector< T > &r) |
Vector assignation. | |
TVector< T > & | operator= (TMatrix< T > &r) |
Matrix assignation (defined in class TMatrix). | |
TVector< T > & | operator= (T *r) |
ANSI assignation (r size must be, at least, N). | |
TVector< T > & | operator= (T r) |
Scalar assignation. | |
bool | operator== (const TVector< T > &r) |
Equality. | |
bool | operator!= (const TVector< T > &r) |
Inequality. | |
TVector< T > | operator+ (const TVector< T > &r) |
Addition. | |
TVector< T > | operator- (const TVector< T > &r) |
Substraction. | |
TVector< T > | operator* (const TVector< T > &r) |
Cross product. | |
TMatrix< T > | operator* (TMatrix< T > &r) |
Matrix product (defined in class TMatrix). | |
TVector< T > | operator* (T r) |
Scalar product. | |
TVector< T > & | operator+= (const TVector< T > &r) |
Addition. | |
TVector< T > & | operator-= (const TVector< T > &r) |
Substraction. | |
TVector< T > & | operator*= (const TVector< T > &r) |
Cross product. | |
TVector< T > & | operator*= (T r) |
Scalar product. | |
TVector< T > | operator- () |
Unary operators. | |
TVector< T > | operator! () |
Normalized vector. | |
TVector< T > | operator~ () |
Transposed vector. |
TVector class.
This class defines a C++ template to use mathematical vectors in a N space.
Definition at line 48 of file vector.h.
gtm::TVector< T >::TVector | ( | uint | N = 3 , |
|
T | data = ( T )0 , |
|||
int | type = 0x02 | |||
) | [inline] |
Default constructor.
Contructors.
N | Cardinality. | |
data | Initial data. | |
type | Vector type (ROW_VECTOR/COL_VECTOR). | |
r | Right object (vector or matrix). | |
block | ANSI array. | |
copy | Make a copy of given array? |
Definition at line 211 of file vector.h.
References gtm::TVector< T >::_myMemory, gtm::TVector< T >::_N, gtm::TVector< T >::_type, and gtm::TVector< T >::_vector.
gtm::TVector< T >::TVector | ( | const TVector< T > & | r | ) | [inline] |
Copy constructor.
Definition at line 223 of file vector.h.
References gtm::TVector< T >::_myMemory, gtm::TVector< T >::_N, gtm::TVector< T >::_type, and gtm::TVector< T >::_vector.
gtm::TVector< T >::TVector | ( | T * | block, | |
uint | N, | |||
bool | copy = true , |
|||
int | type = 0x02 | |||
) | [inline] |
Use this to treat an ANSI array as a TVector.
Definition at line 234 of file vector.h.
References gtm::TVector< T >::_myMemory, gtm::TVector< T >::_N, gtm::TVector< T >::_type, and gtm::TVector< T >::_vector.
gtm::TVector< T >::~TVector | ( | ) | [inline] |
Destructor.
Definition at line 71 of file vector.h.
References gtm::TVector< T >::_myMemory, and gtm::TVector< T >::_vector.
T gtm::TVector< T >::Dot | ( | const TVector< T > & | r | ) | [inline] |
Dot product.
Definition at line 135 of file vector.h.
References gtm::TVector< T >::_N, gtm::TVector< T >::_vector, and GTM_MIN.
T* gtm::TVector< T >::GetAnsiRef | ( | ) | [inline] |
ANSI (C/C++ array) reference.
Definition at line 115 of file vector.h.
References gtm::TVector< T >::_vector.
Referenced by UtilVtk3DGeometriSelection::FindCubePointsFromPoints(), vtk3DSurfaceSTLWidget::FindCubePointsFromPoints(), UtilVtk3DGeometriSelection::GetPointAndNormalIntersection(), vtk3DSurfaceSTLWidget::GetPointAndNormalIntersection(), vtkInteractorStyle3DView::SelectMarchibCubePoint(), vtk3DSurfaceWidget::SetInitialPoint(), and vtk3DSurfaceSTLWidget::SetInitialPoint().
00115 { 00116 return( _vector ); 00117 };
uint gtm::TVector< T >::GetN | ( | ) | [inline] |
Vector's cardinality.
Definition at line 119 of file vector.h.
References gtm::TVector< T >::_N.
Referenced by gtm::TMatrix< T >::operator=().
00119 { 00120 return( _N ); 00121 };
T gtm::TVector< T >::GetNorm | ( | ) | [inline] |
Mathematical norm (L2).
Definition at line 127 of file vector.h.
References gtm::TVector< T >::_N, and gtm::TVector< T >::_vector.
int gtm::TVector< T >::GetType | ( | ) | [inline] |
Vector's type (ROW_VECTOR/COL_VECTOR).
Definition at line 123 of file vector.h.
References gtm::TVector< T >::_type.
Referenced by gtm::TMatrix< T >::operator=().
00123 { 00124 return( _type ); 00125 };
void gtm::TVector< T >::Normalize | ( | ) | [inline] |
Normalizes the vector.
Definition at line 131 of file vector.h.
References gtm::TVector< T >::_N, and gtm::TVector< T >::_vector.
Referenced by UtilVtk3DGeometriSelection::GetPointAndNormalIntersection(), and vtk3DSurfaceSTLWidget::GetPointAndNormalIntersection().
TVector< T > gtm::TVector< T >::operator! | ( | ) | [inline] |
Normalized vector.
Definition at line 358 of file vector.h.
References gtm::TVector< T >::_N, and gtm::TVector< T >::_vector.
bool gtm::TVector< T >::operator!= | ( | const TVector< T > & | r | ) | [inline] |
Inequality.
Definition at line 286 of file vector.h.
References gtm::TVector< T >::_N, and gtm::TVector< T >::_vector.
T& gtm::TVector< T >::operator() | ( | uint | i | ) | [inline] |
Reference operator.
Definition at line 111 of file vector.h.
References gtm::TVector< T >::_vector.
00111 { 00112 return( _vector[ i ] ); 00113 };
TVector< T > gtm::TVector< T >::operator* | ( | T | r | ) | [inline] |
Scalar product.
Definition at line 335 of file vector.h.
References gtm::TVector< T >::_N, and gtm::TVector< T >::_vector.
TMatrix< T > gtm::TVector< T >::operator* | ( | TMatrix< T > & | r | ) | [inline] |
TVector< T > gtm::TVector< T >::operator* | ( | const TVector< T > & | r | ) | [inline] |
Cross product.
Definition at line 324 of file vector.h.
References gtm::TVector< T >::_N, gtm::TVector< T >::_vector, and GTM_MIN.
TVector< T >& gtm::TVector< T >::operator*= | ( | T | r | ) | [inline] |
TVector< T >& gtm::TVector< T >::operator*= | ( | const TVector< T > & | r | ) | [inline] |
TVector< T > gtm::TVector< T >::operator+ | ( | const TVector< T > & | r | ) | [inline] |
Addition.
Binary operators.
r | Right object (vector, matrix or scalar). |
Definition at line 302 of file vector.h.
References gtm::TVector< T >::_N, gtm::TVector< T >::_vector, and GTM_MIN.
TVector< T >& gtm::TVector< T >::operator+= | ( | const TVector< T > & | r | ) | [inline] |
TVector< T > gtm::TVector< T >::operator- | ( | ) | [inline] |
Unary operators.
Additive inverse.
Definition at line 346 of file vector.h.
References gtm::TVector< T >::_N, and gtm::TVector< T >::_vector.
TVector< T > gtm::TVector< T >::operator- | ( | const TVector< T > & | r | ) | [inline] |
Substraction.
Definition at line 313 of file vector.h.
References gtm::TVector< T >::_N, gtm::TVector< T >::_vector, and GTM_MIN.
TVector< T >& gtm::TVector< T >::operator-= | ( | const TVector< T > & | r | ) | [inline] |
TVector< T >& gtm::TVector< T >::operator= | ( | T | r | ) | [inline] |
Scalar assignation.
Definition at line 93 of file vector.h.
References gtm::TVector< T >::_N, and gtm::TVector< T >::_vector.
TVector< T >& gtm::TVector< T >::operator= | ( | T * | r | ) | [inline] |
ANSI assignation (r size must be, at least, N).
Definition at line 88 of file vector.h.
References gtm::TVector< T >::_N, and gtm::TVector< T >::_vector.
TVector< T > & gtm::TVector< T >::operator= | ( | TMatrix< T > & | r | ) | [inline] |
Matrix assignation (defined in class TMatrix).
Definition at line 190 of file matrix.h.
References gtm::TVector< T >::_N, gtm::TVector< T >::_type, gtm::TVector< T >::_vector, COL_VECTOR, gtm::TMatrix< T >::GetM(), gtm::TMatrix< T >::GetN(), GTM_MIN, min, and ROW_VECTOR.
00191 { 00192 uint i, j, k, min; 00193 00194 // This min calc. avoids to reserve temporary memory, so, be careful. 00195 min = GTM_MIN( r.GetN( ) * r.GetM( ), _N ); 00196 _type = ( r.GetN( ) == 1 )? COL_VECTOR: ROW_VECTOR; 00197 for( i = 0, k = 0; i < r.GetN( ) && k < min; i++ ) 00198 for( j = 0; j < r.GetM( ) && k < min; _vector[ k++ ] = r( i, j ), j++ ); 00199 return( *this ); 00200 00201 }
TVector< T > & gtm::TVector< T >::operator= | ( | const TVector< T > & | r | ) | [inline] |
Vector assignation.
Assignation operators.
r | Right object (vector or matrix). |
Definition at line 257 of file vector.h.
References gtm::TVector< T >::_N, gtm::TVector< T >::_type, gtm::TVector< T >::_vector, and GTM_MIN.
bool gtm::TVector< T >::operator== | ( | const TVector< T > & | r | ) | [inline] |
Equality.
Comparation operators.
r | Right object. |
Definition at line 270 of file vector.h.
References gtm::TVector< T >::_N, and gtm::TVector< T >::_vector.
TVector< T > gtm::TVector< T >::operator~ | ( | ) | [inline] |
Transposed vector.
Definition at line 369 of file vector.h.
References gtm::TVector< T >::_type, COL_VECTOR, and ROW_VECTOR.
00370 { 00371 TVector< T > ret = *this; 00372 00373 ret._type = ( _type == COL_VECTOR )? ROW_VECTOR: COL_VECTOR; 00374 return( ret ); 00375 00376 }
void gtm::TVector< T >::SetN | ( | uint | N | ) | [inline] |
Size change.
Definition at line 245 of file vector.h.
References gtm::TVector< T >::_myMemory, gtm::TVector< T >::_N, and gtm::TVector< T >::_vector.
bool gtm::TVector< T >::_myMemory [private] |
Have I created _vector?
Definition at line 204 of file vector.h.
Referenced by gtm::TVector< T >::SetN(), gtm::TVector< T >::TVector(), and gtm::TVector< T >::~TVector().
uint gtm::TVector< T >::_N [private] |
Cardinality.
Definition at line 200 of file vector.h.
Referenced by gtm::TVector< T >::Dot(), gtm::TVector< T >::GetN(), gtm::TVector< T >::GetNorm(), gtm::TVector< T >::Normalize(), gtm::TVector< T >::operator!(), gtm::TVector< T >::operator!=(), gtm::TVector< T >::operator*(), gtm::TVector< T >::operator+(), gtm::TVector< T >::operator-(), gtm::TVector< T >::operator=(), gtm::TVector< T >::operator==(), gtm::TVector< T >::SetN(), and gtm::TVector< T >::TVector().
int gtm::TVector< T >::_type [private] |
Type (ROW_VECTOR/COL_VECTOR).
Definition at line 202 of file vector.h.
Referenced by gtm::TVector< T >::GetType(), gtm::TVector< T >::operator=(), gtm::TVector< T >::operator~(), and gtm::TVector< T >::TVector().
T* gtm::TVector< T >::_vector [private] |
Vector's internal state.
Memory block.
Definition at line 198 of file vector.h.
Referenced by gtm::TVector< T >::Dot(), gtm::TVector< T >::GetAnsiRef(), gtm::TVector< T >::GetNorm(), gtm::TVector< T >::Normalize(), gtm::TVector< T >::operator!(), gtm::TVector< T >::operator!=(), gtm::TVector< T >::operator()(), gtm::TVector< T >::operator*(), gtm::TVector< T >::operator+(), gtm::TVector< T >::operator-(), gtm::TVector< T >::operator=(), gtm::TVector< T >::operator==(), gtm::TVector< T >::SetN(), gtm::TVector< T >::TVector(), and gtm::TVector< T >::~TVector().