Grid3
Public Member Functions | Public Attributes | Friends | List of all members
Vec3< T > Class Template Reference

Class representing 3D vectors, with elements of type T. More...

#include <Vector3.h>

Public Member Functions

 Vec3 (T value=0)
 Constructor accepting a single value, which defaults to 0. All three components are set to the same value. More...
 
 Vec3 (T _x, T _y, T _z)
 Constructor accepting three values, one for each vector component. More...
 
template<class T2 >
 Vec3 (Vec3< T2 > v)
 Copy constructor. More...
 
Vec3< T > operator+ (const Vec3< T > &v) const
 Vector addition. More...
 
Vec3< T > & operator+= (const Vec3< T > &v)
 In-place vector addition. More...
 
Vec3< T > operator- (const Vec3< T > &v) const
 Vector subtraction. More...
 
Vec3< T > & operator-= (const Vec3< T > &v)
 In-place vector subtraction. More...
 
Vec3< T > operator* (const double &d) const
 Multiplication with double. More...
 
Vec3< T > & operator*= (const double &d)
 In-place multiplication with double. More...
 
Vec3< T > operator/ (const double &d) const
 Division with double. More...
 
Vec3< T > & operator/= (const double &d)
 In-place division with double. More...
 
double operator* (const Vec3< T > &v) const
 Scalar product. More...
 
Vec3< T > cross (const Vec3< T > &v) const
 Cross product. More...
 
Vec3< T > operator% (const Vec3< T > &v) const
 Element-wise multiplication (hadamard product) More...
 
Vec3< T > & normalize ()
 Normalize. More...
 
double norm () const
 Vector norm. More...
 
double norm2 () const
 Vector norm squared. More...
 
bool operator== (const Vec3< T > &v) const
 Equal (used for integer position vectors) More...
 
bool operator!= (const Vec3< T > &v) const
 Not equal (used for integer position vectors) More...
 
 operator T ()
 Cast to scalar, simply returns the x component. More...
 

Public Attributes

x
 
y
 
z
 

Friends

Vec3< T > operator* (const double &d, const Vec3< T > &v)
 Multiplication with double. More...
 
std::ostream & operator<< (std::ostream &os, const Vec3< T > &v)
 Write to ostream. More...
 

Detailed Description

template<class T>
class Vec3< T >

Class representing 3D vectors, with elements of type T.

Constructor & Destructor Documentation

template<class T>
Vec3< T >::Vec3 ( value = 0)
inline

Constructor accepting a single value, which defaults to 0. All three components are set to the same value.

template<class T>
Vec3< T >::Vec3 ( _x,
_y,
_z 
)
inline

Constructor accepting three values, one for each vector component.

template<class T>
template<class T2 >
Vec3< T >::Vec3 ( Vec3< T2 >  v)
inline

Copy constructor.

Member Function Documentation

template<class T>
Vec3<T> Vec3< T >::cross ( const Vec3< T > &  v) const
inline

Cross product.

template<class T>
double Vec3< T >::norm ( ) const
inline

Vector norm.

template<class T>
double Vec3< T >::norm2 ( ) const
inline

Vector norm squared.

template<class T>
Vec3<T>& Vec3< T >::normalize ( )
inline

Normalize.

template<class T>
Vec3< T >::operator T ( )
inline

Cast to scalar, simply returns the x component.

template<class T>
bool Vec3< T >::operator!= ( const Vec3< T > &  v) const
inline

Not equal (used for integer position vectors)

template<class T>
Vec3<T> Vec3< T >::operator% ( const Vec3< T > &  v) const
inline

Element-wise multiplication (hadamard product)

template<class T>
Vec3<T> Vec3< T >::operator* ( const double &  d) const
inline

Multiplication with double.

template<class T>
double Vec3< T >::operator* ( const Vec3< T > &  v) const
inline

Scalar product.

template<class T>
Vec3<T>& Vec3< T >::operator*= ( const double &  d)
inline

In-place multiplication with double.

template<class T>
Vec3<T> Vec3< T >::operator+ ( const Vec3< T > &  v) const
inline

Vector addition.

template<class T>
Vec3<T>& Vec3< T >::operator+= ( const Vec3< T > &  v)
inline

In-place vector addition.

template<class T>
Vec3<T> Vec3< T >::operator- ( const Vec3< T > &  v) const
inline

Vector subtraction.

template<class T>
Vec3<T>& Vec3< T >::operator-= ( const Vec3< T > &  v)
inline

In-place vector subtraction.

template<class T>
Vec3<T> Vec3< T >::operator/ ( const double &  d) const
inline

Division with double.

template<class T>
Vec3<T>& Vec3< T >::operator/= ( const double &  d)
inline

In-place division with double.

template<class T>
bool Vec3< T >::operator== ( const Vec3< T > &  v) const
inline

Equal (used for integer position vectors)

Friends And Related Function Documentation

template<class T>
Vec3<T> operator* ( const double &  d,
const Vec3< T > &  v 
)
friend

Multiplication with double.

template<class T>
std::ostream& operator<< ( std::ostream &  os,
const Vec3< T > &  v 
)
friend

Write to ostream.

Member Data Documentation

template<class T>
T Vec3< T >::x
template<class T>
T Vec3< T >::y
template<class T>
T Vec3< T >::z

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