libpsynth 0.2.1
Public Member Functions | Public Attributes
psynth::base::vector_2d< T > Class Template Reference

A bidimensional vector type that can hold any scalar type. More...

#include <vector_2d.hpp>

Collaboration diagram for psynth::base::vector_2d< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 vector_2d (T _x=0, T _y=0)
 Constructor which sets the components of the vector.
void set (T _x, T _y)
 Sets the components of the vector.
T & operator[] (size_t index)
 Accesses the components of the vector by index.
const T & operator[] (size_t index) const
 Accesses the components of the vector by index.
T distance (const vector_2d &v) const
 Returns the distance between this vector and another one.
T sqr_distance (const vector_2d &v) const
 Returns the squared distance between this vector and another one.
T length () const
 Returns the length of the vector.
T sqr_length () const
 Returns the length of the vector.

Public Attributes

T x
 X axis component of the vector.
T y
 Y axis component of the vector.

Detailed Description

template<class T>
class psynth::base::vector_2d< T >

A bidimensional vector type that can hold any scalar type.

Todo:
Add more vector operations and calculations.

Constructor & Destructor Documentation

template<class T>
psynth::base::vector_2d< T >::vector_2d ( T  _x = 0,
T  _y = 0 
) [inline]

Constructor which sets the components of the vector.

Parameters:
_xThe X axis component of the vector.
_xThe Y axis component of the vector.

Member Function Documentation

template<class T>
T psynth::base::vector_2d< T >::distance ( const vector_2d< T > &  v) const [inline]

Returns the distance between this vector and another one.

Parameters:
vThe other vector.
template<class T>
T psynth::base::vector_2d< T >::length ( ) const [inline]

Returns the length of the vector.

template<class T>
T& psynth::base::vector_2d< T >::operator[] ( size_t  index) [inline]

Accesses the components of the vector by index.

The X axis has index 0 and the the Y axis has index 1.

template<class T>
const T& psynth::base::vector_2d< T >::operator[] ( size_t  index) const [inline]

Accesses the components of the vector by index.

The X axis has index 0 and the the Y axis has index 1. Const version.

template<class T>
void psynth::base::vector_2d< T >::set ( T  _x,
T  _y 
) [inline]

Sets the components of the vector.

Parameters:
_xThe X axis component of the vector.
_xThe Y axis component of the vector.
template<class T>
T psynth::base::vector_2d< T >::sqr_distance ( const vector_2d< T > &  v) const [inline]

Returns the squared distance between this vector and another one.

For better efficiency, use this version of the function if you want the distance only for comparison and do not mind about its real value.

Parameters:
vThe other vector.
template<class T>
T psynth::base::vector_2d< T >::sqr_length ( ) const [inline]

Returns the length of the vector.

For better efficiency, use this version of the function if you want the length only for comparison and do not mind about its real value.


Member Data Documentation

template<class T>
T psynth::base::vector_2d< T >::x

X axis component of the vector.

template<class T>
T psynth::base::vector_2d< T >::y

Y axis component of the vector.


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