zsig 1.0.0

zsig::vec< D, T > Class Template Reference

Generic vector type. More...

#include <vec.hh>

List of all members.

Public Types

typedef vec< D, T > vec_type
 This class type.

Public Member Functions

 vec ()
 Default Constructor.
 vec (const vec_type &_v)
 vec (const T &_s)
 ~vec ()
 Destructor.
void clear (void)
 Clear values.
x (void) const
 Get first coordinate value of this vec.
y (void) const
 Get second coordinate value of this vec.
z (void) const
 Get third coordinate value of this vec.
w (void) const
 Get fourth coordinate value of this vec.
sqrl (void) const
 Squared-length of this vector ||v||^2.
length (void) const
 Length of this vector ||v||.
angle (const vec_type &_v) const
 Angle between vectors.
vec_type normal (void) const
 Get this vector normalized.
vec_type normalize (void)
 Normalize and return this vector.
vec_type normalize (const T &_l)
vec_typeoperator= (const vec_type &_v)
 Assign operator from vec.
vec_typeoperator= (const T &_s)
 Assign operator.
vec_type operator- (void) const
 Negation operator.
vec_type operator+ (const T &_s) const
 Sum operator.
vec_type operator+ (const vec_type &_v) const
 Sum operator.
vec_typeoperator+= (const vec_type &_v)
 Sum operator.
vec_type operator- (const T &_s) const
 Subtract operator.
vec_type operator- (const vec_type &_v) const
 Subtract operator.
vec_typeoperator-= (const vec_type &_v)
 Subtract operator.
vec_type operator* (const T &_s) const
 Multiply operator.
vec_type operator* (const vec_type &_v) const
 Multiply operator.
vec_typeoperator*= (const T &_s)
 Multiply operator.
vec_typeoperator*= (const vec_type &_v)
 Multiply operator.
vec_type operator/ (const T &_s) const
 Division operator.
vec_type operator/ (const vec_type &_v) const
 Division operator.
vec_typeoperator/= (const T &_s)
 Division operator.
vec_typeoperator/= (const vec_type &_v)
 Division operator.
operator^ (const vec_type &_v) const
 Dot-product operator.
vec_type operator% (const vec_type &_v) const
 Cross-product operator.
T & operator[] (const unsigned &_i)
 Read/write operator.
const T & operator[] (const unsigned &_i) const
 Read operator.
const T * operator& (void) const
 Address operator.

Protected Attributes

coord [D]
 D (dimension) coordinate values of type T.

Friends

vec_type operator* (const T &_s, const vec_type &_v)
 Multiply operator.
bool operator== (const vec_type &_v1, const vec_type &_v2)
 Equality-test operator.
bool operator== (const vec_type &_v1, T &_s2)
 Equality-test operator.
bool operator!= (const vec_type &_v1, const vec_type &_v2)
 Inequality-test operator.
bool operator!= (const vec_type &_v1, T &_s2)
 Inequality-test operator.
std::ostream & operator<< (std::ostream &out, const vec_type &_v)
 Output stream operator.
std::istream & operator>> (std::istream &in, vec_type &_v)
 Intput stream operator.

Related Functions

(Note that these are not member functions.)
template<unsigned D, class T >
void project_vertex (vec< D, T > &_v, const vec< D, T > &_n, const vec< D, T > &_p)
 Project vertex on a plane.

Detailed Description

template<unsigned D, class T>
class zsig::vec< D, T >

Generic vector type.

Template class for an array of values, such as vector or points, where the dimension is also defined as a template, e.g. vec< 3, double > p; defines a point p in R^3 with double precision coordinates. Note that it was supposed to be used as a vector or point in D dimension, if an array-like vector is intended use valarray class in STL instead.

Template Parameters:
DVector dimension
TVector value type

Definition at line 36 of file vec.hh.


Member Typedef Documentation

template<unsigned D, class T>
typedef vec< D, T > zsig::vec< D, T >::vec_type

This class type.

Definition at line 40 of file vec.hh.


Constructor & Destructor Documentation

template<unsigned D, class T>
zsig::vec< D, T >::vec ( ) [inline]

Default Constructor.

Definition at line 43 of file vec.hh.

template<unsigned D, class T>
zsig::vec< D, T >::vec ( const vec_type _v) [inline]

Copy Constructor

Parameters:
_vOther vec to copy values from

Definition at line 48 of file vec.hh.

template<unsigned D, class T>
zsig::vec< D, T >::vec ( const T &  _s) [inline]

Constructor from scalar value

Parameters:
_sScalar value to set all coordinates

Definition at line 53 of file vec.hh.

template<unsigned D, class T>
zsig::vec< D, T >::~vec ( ) [inline]

Destructor.

Definition at line 56 of file vec.hh.


Member Function Documentation

template<unsigned D, class T>
void zsig::vec< D, T >::clear ( void  ) [inline]

Clear values.

Definition at line 59 of file vec.hh.

template<unsigned D, class T>
T zsig::vec< D, T >::x ( void  ) const [inline]

Get first coordinate value of this vec.

Returns:
Coordinate x

Definition at line 64 of file vec.hh.

template<unsigned D, class T>
T zsig::vec< D, T >::y ( void  ) const [inline]

Get second coordinate value of this vec.

Returns:
Coordinate y

Definition at line 69 of file vec.hh.

template<unsigned D, class T>
T zsig::vec< D, T >::z ( void  ) const [inline]

Get third coordinate value of this vec.

Returns:
Coordinate z

Definition at line 74 of file vec.hh.

template<unsigned D, class T>
T zsig::vec< D, T >::w ( void  ) const [inline]

Get fourth coordinate value of this vec.

Returns:
Coordinate w

Definition at line 79 of file vec.hh.

template<unsigned D, class T>
T zsig::vec< D, T >::sqrl ( void  ) const [inline]

Squared-length of this vector ||v||^2.

Returns:
Vector squared-length value

Definition at line 84 of file vec.hh.

template<unsigned D, class T>
T zsig::vec< D, T >::length ( void  ) const [inline]

Length of this vector ||v||.

Returns:
Vector length value

Definition at line 89 of file vec.hh.

template<unsigned D, class T>
T zsig::vec< D, T >::angle ( const vec_type _v) const [inline]

Angle between vectors.

Parameters:
_vVector to compute the angle with
Returns:
Angle in radians between this vector and v

Definition at line 95 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::normal ( void  ) const [inline]

Get this vector normalized.

Returns:
Normalized vector

Definition at line 100 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::normalize ( void  ) [inline]

Normalize and return this vector.

Returns:
Normalized vector

Definition at line 105 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::normalize ( const T &  _l) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
_lLength used to normalize this vector
Returns:
Normalized vector

Definition at line 112 of file vec.hh.

template<unsigned D, class T>
vec_type& zsig::vec< D, T >::operator= ( const vec_type _v) [inline]

Assign operator from vec.

Parameters:
_vVec to get values from
Returns:
This vec with assigned values

Definition at line 118 of file vec.hh.

template<unsigned D, class T>
vec_type& zsig::vec< D, T >::operator= ( const T &  _s) [inline]

Assign operator.

Parameters:
_sScalar value to copy to all coordinates
Returns:
This vec with assigned values

Definition at line 127 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::operator- ( void  ) const [inline]

Negation operator.

Returns:
Vec with negated values

Definition at line 135 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::operator+ ( const T &  _s) const [inline]

Sum operator.

Parameters:
_sScalar value to sum up
Returns:
Vec resulting from summation

Definition at line 145 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::operator+ ( const vec_type _v) const [inline]

Sum operator.

Parameters:
_vVec to sum up
Returns:
Vec resulting from summation

Definition at line 155 of file vec.hh.

template<unsigned D, class T>
vec_type& zsig::vec< D, T >::operator+= ( const vec_type _v) [inline]

Sum operator.

Parameters:
_vVec to sum up
Returns:
This vec resulting from summation

Definition at line 165 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::operator- ( const T &  _s) const [inline]

Subtract operator.

Parameters:
_sScalar value to subtract down
Returns:
Vec resulting from subtraction

Definition at line 174 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::operator- ( const vec_type _v) const [inline]

Subtract operator.

Parameters:
_vVec to subtract down
Returns:
Vec resulting from subtraction

Definition at line 184 of file vec.hh.

template<unsigned D, class T>
vec_type& zsig::vec< D, T >::operator-= ( const vec_type _v) [inline]

Subtract operator.

Parameters:
_vVec to subtract down
Returns:
This vec resulting from subtraction

Definition at line 194 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::operator* ( const T &  _s) const [inline]

Multiply operator.

Parameters:
_sScalar value to multiply
Returns:
Vec resulting from multiplication

Definition at line 203 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::operator* ( const vec_type _v) const [inline]

Multiply operator.

Parameters:
_vVec to multiply
Returns:
Vec resulting from multiplication

Definition at line 213 of file vec.hh.

template<unsigned D, class T>
vec_type& zsig::vec< D, T >::operator*= ( const T &  _s) [inline]

Multiply operator.

Parameters:
_sScalar value to multiply
Returns:
This vec resulting from multiplication

Definition at line 223 of file vec.hh.

template<unsigned D, class T>
vec_type& zsig::vec< D, T >::operator*= ( const vec_type _v) [inline]

Multiply operator.

Parameters:
_vVec to multiply
Returns:
This vec resulting from multiplication

Definition at line 232 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::operator/ ( const T &  _s) const [inline]

Division operator.

Parameters:
_sScalar value to divide
Returns:
Vec resulting from subdivision

Definition at line 251 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::operator/ ( const vec_type _v) const [inline]

Division operator.

Parameters:
_vVec to divide
Returns:
Vec resulting from subdivision

Definition at line 262 of file vec.hh.

template<unsigned D, class T>
vec_type& zsig::vec< D, T >::operator/= ( const T &  _s) [inline]

Division operator.

Parameters:
_sScalar value to divide
Returns:
This vec resulting from subdivision

Definition at line 274 of file vec.hh.

template<unsigned D, class T>
vec_type& zsig::vec< D, T >::operator/= ( const vec_type _v) [inline]

Division operator.

Parameters:
_vVec to divide
Returns:
This vec resulting from subdivision

Definition at line 284 of file vec.hh.

template<unsigned D, class T>
T zsig::vec< D, T >::operator^ ( const vec_type _v) const [inline]

Dot-product operator.

Parameters:
_vVec to do dot-product
Returns:
Value resulting from dot-product

Definition at line 295 of file vec.hh.

template<unsigned D, class T>
vec_type zsig::vec< D, T >::operator% ( const vec_type _v) const [inline]

Cross-product operator.

Parameters:
_vVec to do cross-product
Returns:
Vec resulting from cross-product

Definition at line 305 of file vec.hh.

template<unsigned D, class T>
T& zsig::vec< D, T >::operator[] ( const unsigned &  _i) [inline]

Read/write operator.

Parameters:
_iIndex of coordinate value
Returns:
Coordinate value at index

Definition at line 393 of file vec.hh.

template<unsigned D, class T>
const T& zsig::vec< D, T >::operator[] ( const unsigned &  _i) const [inline]

Read operator.

Parameters:
_iIndex of coordinate value
Returns:
Constant coordinate value at index

Definition at line 400 of file vec.hh.

template<unsigned D, class T>
const T* zsig::vec< D, T >::operator& ( void  ) const [inline]

Address operator.

Returns:
Constant address value of this vec coordinates

Definition at line 406 of file vec.hh.


Friends And Related Function Documentation

template<unsigned D, class T>
vec_type operator* ( const T &  _s,
const vec_type _v 
) [friend]

Multiply operator.

Parameters:
_sScalar value to multiply from left-side
_vVec to multiply to right-side
Returns:
Vec resulting from multiplication

Definition at line 242 of file vec.hh.

template<unsigned D, class T>
bool operator== ( const vec_type _v1,
const vec_type _v2 
) [friend]

Equality-test operator.

Parameters:
_v1Vec to test from left-side
_v2Vec to test to right-side
Returns:
True if the two vecs are equal

Definition at line 318 of file vec.hh.

template<unsigned D, class T>
bool operator== ( const vec_type _v1,
T &  _s2 
) [friend]

Equality-test operator.

Parameters:
_v1Vec to test from left-side
_s2Scalar value to test to right-side
Returns:
True if the vec coordinates are all equal to the scalar value

Definition at line 329 of file vec.hh.

template<unsigned D, class T>
bool operator!= ( const vec_type _v1,
const vec_type _v2 
) [friend]

Inequality-test operator.

Parameters:
_v1Vec to test from left-side
_v2Vec to test to right-side
Returns:
True if the two vecs are not-equal

Definition at line 341 of file vec.hh.

template<unsigned D, class T>
bool operator!= ( const vec_type _v1,
T &  _s2 
) [friend]

Inequality-test operator.

Parameters:
_v1Vec to test from left-side
_s2Scalar value to test to right-side
Returns:
True if the vec coordinates are all not-equal to the scalar value

Definition at line 353 of file vec.hh.

template<unsigned D, class T>
std::ostream& operator<< ( std::ostream &  out,
const vec_type _v 
) [friend]

Output stream operator.

Parameters:
outOutput stream
_vVec to output values from
Returns:
Output stream

Definition at line 366 of file vec.hh.

template<unsigned D, class T>
std::istream& operator>> ( std::istream &  in,
vec_type _v 
) [friend]

Intput stream operator.

Parameters:
inInput stream
_vVec to input values to
Returns:
Input stream

Definition at line 381 of file vec.hh.

template<unsigned D, class T >
void project_vertex ( vec< D, T > &  _v,
const vec< D, T > &  _n,
const vec< D, T > &  _p 
) [related]

Project vertex on a plane.

Parameters:
[in,out]_vVertex to be projected
[in]_nNormal of the plane
[in]_pPoint on the plane
Template Parameters:
DVector/point dimension
TVector/point value type

Definition at line 425 of file vec.hh.


Member Data Documentation

template<unsigned D, class T>
T zsig::vec< D, T >::coord[D] [protected]

D (dimension) coordinate values of type T.

Definition at line 410 of file vec.hh.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Friends