GEL
2
GEL is a library for Geometry and Linear Algebra
|
Template representing generic arithmetic vectors. More...
#include <ArithVec.h>
Inherited by CGLA::ArithVecFloat< double, Vec2d, 2 >, CGLA::ArithVecFloat< double, Vec3d, 3 >, CGLA::ArithVecFloat< double, Vec4d, 4 >, CGLA::ArithVecFloat< float, Vec2f, 2 >, CGLA::ArithVecFloat< float, Vec3f, 3 >, CGLA::ArithVecFloat< float, Vec4f, 4 >, CGLA::ArithVecFloat< T, V, 2 >, CGLA::ArithVecFloat< T, V, 3 >, CGLA::ArithVecFloat< T, V, 4 >, CGLA::ArithVecInt< int, Vec3i, 3 >, CGLA::ArithVecInt< int, Vec3usi, 3 >, CGLA::ArithVecInt< int, Vec4i, 4 >, CGLA::ArithVecInt< T, V, 3 >, CGLA::ArithVecInt< T, V, 4 >, CGLA::ArithVecInt< UChar, Vec3uc, 3 >, CGLA::ArithVecFloat< T, V, N >, and CGLA::ArithVecInt< T, V, N >.
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 | |
T | data [N] |
The actual contents of the vector. |
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.
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.
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.
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.
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.
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)
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).
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.
const V& CGLA::ArithVec< T, V, N >::operator*= | ( | const V & | v | ) | [inline] |
Assignment multiplication with vector. Multiply each coord independently.