Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::TVector2< T > Struct Template Reference

Parameterizable two-dimensional vector data structure. More...

#include <mitsuba/mitsuba.h>

Public Types

typedef T Scalar
 
typedef TPoint2< T > PointType
 
typedef detail::VectorLength
< T, std::numeric_limits< T >
::is_integer >::type 
LengthType
 

Public Member Functions

 TVector2 ()
 Construct a new vector without initializing it. More...
 
 TVector2 (T x, T y)
 Initialize the vector with the specified X and Z components. More...
 
 TVector2 (T val)
 Initialize all components of the the vector with the specified value. More...
 
template<typename T2 >
 TVector2 (const TVector2< T2 > &v)
 Initialize the vector with the components of another vector data structure. More...
 
template<typename T2 >
 TVector2 (const TPoint2< T2 > &p)
 Initialize the vector with the components of a point data structure. More...
 
 TVector2 (Stream *stream)
 Unserialize a vector from a binary data stream. More...
 
TVector2 operator+ (const TVector2 &v) const
 Add two vectors and return the result. More...
 
TVector2 operator- (const TVector2 &v) const
 Subtract two vectors and return the result. More...
 
TVector2operator+= (const TVector2 &v)
 Add another vector to the current one. More...
 
TVector2operator-= (const TVector2 &v)
 Subtract another vector from the current one. More...
 
TVector2 operator* (T f) const
 Multiply the vector by the given scalar and return the result. More...
 
TVector2operator*= (T f)
 Multiply the vector by the given scalar. More...
 
TVector2 operator- () const
 Return a negated version of the vector. More...
 
TVector2 operator/ (T f) const
 Divide the vector by the given scalar and return the result. More...
 
TVector2operator/= (T f)
 Divide the vector by the given scalar. More...
 
T & operator[] (int i)
 Index into the vector's components. More...
 
operator[] (int i) const
 Index into the vector's components (const version) More...
 
lengthSquared () const
 Return the squared 2-norm of this vector. More...
 
LengthType length () const
 Return the 2-norm of this vector. More...
 
bool isZero () const
 Return whether or not this vector is identically zero. More...
 
bool operator== (const TVector2 &v) const
 Equality test. More...
 
bool operator!= (const TVector2 &v) const
 Inequality test. More...
 
void serialize (Stream *stream) const
 Serialize this vector to a binary data stream. More...
 
std::string toString () const
 Return a readable string representation of this vector. More...
 

Public Attributes

x
 
y
 

Static Public Attributes

static const int dim = 2
 Number of dimensions. More...
 

Detailed Description

template<typename T>
struct mitsuba::TVector2< T >

Parameterizable two-dimensional vector data structure.

Member Typedef Documentation

template<typename T>
typedef detail::VectorLength<T, std::numeric_limits<T>::is_integer>::type mitsuba::TVector2< T >::LengthType
template<typename T>
typedef TPoint2<T> mitsuba::TVector2< T >::PointType
template<typename T>
typedef T mitsuba::TVector2< T >::Scalar

Constructor & Destructor Documentation

template<typename T>
mitsuba::TVector2< T >::TVector2 ( )
inline

Construct a new vector without initializing it.

This construtor is useful when the vector will either not be used at all (it might be part of a larger data structure) or initialized at a later point in time. Always make sure that one of the two is the case! Otherwise your program will do computations involving uninitialized memory, which will probably lead to a difficult-to-find bug.

template<typename T>
mitsuba::TVector2< T >::TVector2 ( x,
y 
)
inline

Initialize the vector with the specified X and Z components.

template<typename T>
mitsuba::TVector2< T >::TVector2 ( val)
inlineexplicit

Initialize all components of the the vector with the specified value.

template<typename T>
template<typename T2 >
mitsuba::TVector2< T >::TVector2 ( const TVector2< T2 > &  v)
inlineexplicit

Initialize the vector with the components of another vector data structure.

template<typename T>
template<typename T2 >
mitsuba::TVector2< T >::TVector2 ( const TPoint2< T2 > &  p)
inlineexplicit

Initialize the vector with the components of a point data structure.

template<typename T>
mitsuba::TVector2< T >::TVector2 ( Stream stream)
inlineexplicit

Unserialize a vector from a binary data stream.

Member Function Documentation

template<typename T>
bool mitsuba::TVector2< T >::isZero ( ) const
inline

Return whether or not this vector is identically zero.

template<typename T>
LengthType mitsuba::TVector2< T >::length ( ) const
inline

Return the 2-norm of this vector.

template<typename T>
T mitsuba::TVector2< T >::lengthSquared ( ) const
inline

Return the squared 2-norm of this vector.

template<typename T>
bool mitsuba::TVector2< T >::operator!= ( const TVector2< T > &  v) const
inline

Inequality test.

template<typename T>
TVector2 mitsuba::TVector2< T >::operator* ( f) const
inline

Multiply the vector by the given scalar and return the result.

template<typename T>
TVector2& mitsuba::TVector2< T >::operator*= ( f)
inline

Multiply the vector by the given scalar.

template<typename T>
TVector2 mitsuba::TVector2< T >::operator+ ( const TVector2< T > &  v) const
inline

Add two vectors and return the result.

template<typename T>
TVector2& mitsuba::TVector2< T >::operator+= ( const TVector2< T > &  v)
inline

Add another vector to the current one.

template<typename T>
TVector2 mitsuba::TVector2< T >::operator- ( const TVector2< T > &  v) const
inline

Subtract two vectors and return the result.

template<typename T>
TVector2 mitsuba::TVector2< T >::operator- ( ) const
inline

Return a negated version of the vector.

template<typename T>
TVector2& mitsuba::TVector2< T >::operator-= ( const TVector2< T > &  v)
inline

Subtract another vector from the current one.

template<typename T>
TVector2 mitsuba::TVector2< T >::operator/ ( f) const
inline

Divide the vector by the given scalar and return the result.

template<typename T>
TVector2& mitsuba::TVector2< T >::operator/= ( f)
inline

Divide the vector by the given scalar.

template<typename T>
bool mitsuba::TVector2< T >::operator== ( const TVector2< T > &  v) const
inline

Equality test.

template<typename T>
T& mitsuba::TVector2< T >::operator[] ( int  i)
inline

Index into the vector's components.

template<typename T>
T mitsuba::TVector2< T >::operator[] ( int  i) const
inline

Index into the vector's components (const version)

template<typename T>
void mitsuba::TVector2< T >::serialize ( Stream stream) const
inline

Serialize this vector to a binary data stream.

template<typename T>
std::string mitsuba::TVector2< T >::toString ( ) const
inline

Return a readable string representation of this vector.

Member Data Documentation

template<typename T>
const int mitsuba::TVector2< T >::dim = 2
static

Number of dimensions.

template<typename T>
T mitsuba::TVector2< T >::x
template<typename T>
T mitsuba::TVector2< T >::y

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