ork::vec2< type > Class Template Reference [math]

A 2D vector. More...

`#include <vec2.h>`

List of all members.

Public Member Functions

vec2 ()
Creates a new, uninitialized vector.
vec2 (type xi, type yi)
Creates a new vector with the given coordinates.
vec2 (const type v[2])
Creates a new vector with the given coordinates.
vec2 (const vec2 &v)
Creates a new vector as a copy of the given vector.
type operator[] (const int i) const
Returns the coordinate of this vector whose index is given.
type & operator[] (const int i)
Returns the coordinate of this vector whose index is given.
void operator= (const vec2 &v)
Assigns the given vector to this vector.
bool operator== (const vec2 &v) const
Returns true if this vector is equal to the given vector.
bool operator!= (const vec2 &v) const
Returns true if this vector is different from the given vector.
vec2 operator+ (const vec2 &v) const
Returns the sum of this vector and of the given vector.
vec2 operator- (const vec2 &v) const
Returns the difference of this vector and of the given vector.
vec2 operator* (const vec2 &v) const
Returns the product of this vector and of the given vector.
vec2 operator* (const type scalar) const
Returns the product of this vector and of the given scalar.
vec2 operator/ (const vec2 &v) const
Returns the division of this vector and of the given vector.
vec2 operator/ (const type scalar) const
Returns the division of this vector and of the given scalar.
vec2 operator- () const
Returns the opposite of this vector.
vec2operator+= (const vec2 &v)
Adds the given vector to this vector.
vec2operator-= (const vec2 &v)
Substracts the given vector from this vector.
vec2operator*= (const type scalar)
Multiplies this vector by the given scalar.
vec2operator/= (const type scalar)
Divides this vector by the given scalar.
bool operator< (const vec2 &v) const
Compare first element, then second if equal.
type length () const
Returns the length of this vector.
type squaredLength () const
Returns the squared length of this vector.
type dotproduct (const vec2 &v) const
Returns the dot product of this vector and of the given vector.
type dot (const vec2 &v) const
Alias for dotproduct, here for compatibility.
vec2 normalize () const
Returns this vector normalized to unit length.
vec2 normalize (type l) const
Returns this vector normalized to the given length.
vec2 normalize (type *previousLength) const
Returns this vector normalized to unit length.
vec2 normalize (type l, type *previousLength)
Returns this vector normalized to the given length.
template<class t >
vec2< t > cast ()
Casts this vector to another base type.

type x
x coordinate.
type y
x coordinate.

Static Public Attributes

static const vec2 ZERO
The null vector (0,0).
static const vec2 UNIT_X
The unit x vector (1,0).
static const vec2 UNIT_Y
The unit y vector (0,1).

A 2D vector.

Constructor & Destructor Documentation

template<typename type >
 ork::vec2< type >::vec2 ( ) ` [inline]`

Creates a new, uninitialized vector.

template<typename type>
 ork::vec2< type >::vec2 ( type xi, type yi ) ` [inline]`

Creates a new vector with the given coordinates.

template<typename type>
 ork::vec2< type >::vec2 ( const type v[2] ) ` [inline]`

Creates a new vector with the given coordinates.

template<typename type>
 ork::vec2< type >::vec2 ( const vec2< type > & v ) ` [inline]`

Creates a new vector as a copy of the given vector.

Member Function Documentation

template<typename type>
template<class t >
 vec2 ork::vec2< type >::cast ( ) ` [inline]`

Casts this vector to another base type.

template<typename type >
 type ork::vec2< type >::dot ( const vec2< type > & v ) const` [inline]`

Alias for dotproduct, here for compatibility.

template<typename type >
 type ork::vec2< type >::dotproduct ( const vec2< type > & v ) const` [inline]`

Returns the dot product of this vector and of the given vector.

template<typename type >
 type ork::vec2< type >::length ( ) const` [inline]`

Returns the length of this vector.

template<typename type>
 vec2< type > ork::vec2< type >::normalize ( type l, type * previousLength ) ` [inline]`

Returns this vector normalized to the given length.

Returns also its initial length.

template<typename type>
 vec2< type > ork::vec2< type >::normalize ( type * previousLength ) const` [inline]`

Returns this vector normalized to unit length.

Returns also its initial length.

template<typename type>
 vec2< type > ork::vec2< type >::normalize ( type l ) const` [inline]`

Returns this vector normalized to the given length.

template<typename type >
 vec2< type > ork::vec2< type >::normalize ( ) const` [inline]`

Returns this vector normalized to unit length.

template<typename type >
 bool ork::vec2< type >::operator!= ( const vec2< type > & v ) const` [inline]`

Returns true if this vector is different from the given vector.

template<typename type>
 vec2< type > ork::vec2< type >::operator* ( const type scalar ) const` [inline]`

Returns the product of this vector and of the given scalar.

template<typename type >
 vec2< type > ork::vec2< type >::operator* ( const vec2< type > & v ) const` [inline]`

Returns the product of this vector and of the given vector.

The product is done component by component.

template<typename type>
 vec2< type > & ork::vec2< type >::operator*= ( const type scalar ) ` [inline]`

Multiplies this vector by the given scalar.

template<typename type >
 vec2< type > ork::vec2< type >::operator+ ( const vec2< type > & v ) const` [inline]`

Returns the sum of this vector and of the given vector.

template<typename type >
 vec2< type > & ork::vec2< type >::operator+= ( const vec2< type > & v ) ` [inline]`

Adds the given vector to this vector.

template<typename type >
 vec2< type > ork::vec2< type >::operator- ( ) const` [inline]`

Returns the opposite of this vector.

template<typename type >
 vec2< type > ork::vec2< type >::operator- ( const vec2< type > & v ) const` [inline]`

Returns the difference of this vector and of the given vector.

template<typename type >
 vec2< type > & ork::vec2< type >::operator-= ( const vec2< type > & v ) ` [inline]`

Substracts the given vector from this vector.

template<typename type>
 vec2< type > ork::vec2< type >::operator/ ( const type scalar ) const` [inline]`

Returns the division of this vector and of the given scalar.

template<typename type >
 vec2< type > ork::vec2< type >::operator/ ( const vec2< type > & v ) const` [inline]`

Returns the division of this vector and of the given vector.

The division is done component by component.

template<typename type>
 vec2< type > & ork::vec2< type >::operator/= ( const type scalar ) ` [inline]`

Divides this vector by the given scalar.

template<typename type >
 bool ork::vec2< type >::operator< ( const vec2< type > & v ) const` [inline]`

Compare first element, then second if equal.

template<typename type >
 void ork::vec2< type >::operator= ( const vec2< type > & v ) ` [inline]`

Assigns the given vector to this vector.

template<typename type >
 bool ork::vec2< type >::operator== ( const vec2< type > & v ) const` [inline]`

Returns true if this vector is equal to the given vector.

template<typename type >
 type & ork::vec2< type >::operator[] ( const int i ) ` [inline]`

Returns the coordinate of this vector whose index is given.

template<typename type >
 type ork::vec2< type >::operator[] ( const int i ) const` [inline]`

Returns the coordinate of this vector whose index is given.

template<typename type >
 type ork::vec2< type >::squaredLength ( ) const` [inline]`

Returns the squared length of this vector.

Member Data Documentation

template<typename type>
 const vec2< type > ork::vec2< type >::UNIT_X` [inline, static]`

The unit x vector (1,0).

template<typename type>
 const vec2< type > ork::vec2< type >::UNIT_Y` [inline, static]`

The unit y vector (0,1).

template<typename type>
 type ork::vec2< type >::x

x coordinate.

template<typename type>
 type ork::vec2< type >::y

x coordinate.

template<typename type>
 const vec2< type > ork::vec2< type >::ZERO` [inline, static]`

The null vector (0,0).

Generated on Mon Oct 18 09:36:08 2010 for ork by  1.6.1