DSC
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CGLA::ArithVec< T, V, N > Class Template Reference

Template representing generic arithmetic vectors. More...

#include <ArithVec.h>

Inheritance diagram for CGLA::ArithVec< T, V, N >:
CGLA::ArithVecFloat< T, V, 2 > CGLA::ArithVecFloat< T, V, 3 > CGLA::ArithVecFloat< T, V, 4 > CGLA::ArithVecInt< T, V, 3 > CGLA::ArithVecInt< T, V, 4 > CGLA::ArithVecFloat< T, V, N > CGLA::ArithVecInt< T, V, N > CGLA::ArithVec2Float< T, V > CGLA::ArithVec3Float< T, V > CGLA::ArithVec4Float< T, V > CGLA::ArithVec3Int< T, V > CGLA::ArithVec4Int< T, V >

Public Types

typedef T ScalarType
 For convenience we define a more meaningful name for the scalar type.
 
typedef V VectorType
 A more meaningful name for vector type.
 

Public Member Functions

void set (T _a, T _b)
 Set all coordinates of a 2D vector.
 
void set (T _a, T _b, T _c)
 Set all coordinates of a 3D vector.
 
void set (T _a, T _b, T _c, T _d)
 Set all coordinates of a 4D vector.
 
const T & operator[] (unsigned int i) const
 Const index operator.
 
T & operator[] (unsigned int i)
 Non-const index operator.
 
const T & operator() (unsigned int i) const
 Const index operator.
 
T & operator() (unsigned int i)
 Non-const index operator.
 
T * get ()
 
const T * get () const
 
bool operator== (const V &v) const
 Equality operator.
 
bool operator== (T k) const
 Equality wrt scalar. True if all coords are equal to scalar.
 
bool operator!= (const V &v) const
 Inequality operator.
 
bool operator!= (T k) const
 Inequality wrt scalar. True if any coord not equal to scalar.
 
bool all_l (const V &v) const
 
bool all_le (const V &v) const
 
bool all_g (const V &v) const
 
bool all_ge (const V &v) const
 
const V & operator*= (T k)
 Assignment multiplication with scalar.
 
const V & operator/= (T k)
 Assignment division with scalar.
 
const V & operator+= (T k)
 Assignment addition with scalar. Adds scalar to each coordinate.
 
const V & operator-= (T k)
 Assignment subtraction with scalar. Subtracts scalar from each coord.
 
const V & operator*= (const V &v)
 
const V & operator/= (const V &v)
 Assigment division with vector. Each coord divided independently.
 
const V & operator+= (const V &v)
 Assignmment addition with vector.
 
const V & operator-= (const V &v)
 Assignment subtraction with vector.
 
const V operator- () const
 Negate vector.
 
const V operator* (const V &v1) const
 
const V operator+ (const V &v1) const
 Add two vectors.
 
const V operator- (const V &v1) const
 Subtract two vectors.
 
const V operator/ (const V &v1) const
 Divide two vectors. Each coord separately.
 
const V operator* (T k) const
 Multiply scalar onto vector.
 
const V operator/ (T k) const
 Divide vector by scalar.
 
const T min_coord () const
 Return the smallest coordinate of the vector.
 
const T max_coord () const
 Return the largest coordinate of the vector.
 

Static Public Member Functions

static unsigned int get_dim ()
 Return dimension of vector.
 

Protected Member Functions

 ArithVec ()
 Construct uninitialized vector.
 
 ArithVec (T _a)
 Construct a vector where all coordinates are identical.
 
 ArithVec (T _a, T _b)
 Construct a 2D vector.
 
 ArithVec (T _a, T _b, T _c)
 Construct a 3D vector.
 
 ArithVec (T _a, T _b, T _c, T _d)
 Construct a 4D vector.
 

Protected Attributes

data [N]
 The actual contents of the vector.
 

Detailed Description

template<class T, class V, unsigned int N>
class CGLA::ArithVec< T, V, N >

Template representing generic arithmetic vectors.

The three parameters to the template are

T - the scalar type (i.e. float, int, double etc.)

V - the name of the vector type. This template is always (and only) used as ancestor of concrete types, and the name of the class inheriting from this class is used as the V argument.

N - The final argument is the dimension N. For instance, N=3 for a 3D vector.

This class template contains all functions that are assumed to be the same for any arithmetic vector - regardless of dimension or the type of scalars used for coordinates.

The template contains no virtual functions which is important since they add overhead.

Member Function Documentation

template<class T, class V, unsigned int N>
bool CGLA::ArithVec< T, V, N >::all_g ( const V &  v) const
inline

Compare all coordinates against other vector. ( > ) Similar to testing whether we are on one side of three planes.

template<class T, class V, unsigned int N>
bool CGLA::ArithVec< T, V, N >::all_ge ( const V &  v) const
inline

Compare all coordinates against other vector. ( >= ) Similar to testing whether we are on one side of three planes.

template<class T, class V, unsigned int N>
bool CGLA::ArithVec< T, V, N >::all_l ( const V &  v) const
inline

Compare all coordinates against other vector. ( < ) Similar to testing whether we are on one side of three planes.

template<class T, class V, unsigned int N>
bool CGLA::ArithVec< T, V, N >::all_le ( const V &  v) const
inline

Compare all coordinates against other vector. ( <= ) Similar to testing whether we are on one side of three planes.

template<class T, class V, unsigned int N>
T* CGLA::ArithVec< T, V, N >::get ( )
inline

Get a pointer to first element in data array. This function may be useful when interfacing with some other API such as OpenGL (TM)

template<class T, class V, unsigned int N>
const T* CGLA::ArithVec< T, V, N >::get ( ) const
inline

Get a const pointer to first element in data array. This function may be useful when interfacing with some other API such as OpenGL (TM).

template<class T, class V, unsigned int N>
const V CGLA::ArithVec< T, V, N >::operator* ( const V &  v1) const
inline

Multiply vector with vector. Each coord multiplied independently Do not confuse this operation with dot product.

template<class T, class V, unsigned int N>
const V& CGLA::ArithVec< T, V, N >::operator*= ( const V &  v)
inline

Assignment multiplication with vector. Multiply each coord independently.


The documentation for this class was generated from the following file: