Back to index

nux  3.0.0
Public Member Functions | Public Attributes | Friends
nux::Vec2< T > Class Template Reference

#include <Vector2.h>

Inheritance diagram for nux::Vec2< T >:
Inheritance graph
[legend]
Collaboration diagram for nux::Vec2< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Vec2 ()
 ~Vec2 ()
 Vec2 (const T &, const T &)
 Vec2 (const Vec2 &)
Vec2< T > & operator= (const Vec2< T > &)
bool operator== (const Vec2< T > &) const
bool operator!= (const Vec2< T > &) const
Vec2< T > operator+ (const Vec2< T > &) const
Vec2< T > operator* (const Vec2< T > &) const
Vec2< T > operator- (const Vec2< T > &) const
Vec2< T > operator- () const
Vec2< T > & operator*= (const Vec2< T > &)
Vec2< T > & operator+= (const Vec2< T > &)
Vec2< T > & operator-= (const Vec2< T > &)
Vec2< T > operator/ (const T &) const
Vec2< T > operator* (const T &) const
T & operator[] (int i)
 element access
const T & operator[] (int i) const
 element access (const)
Length () const
DotProduct (const Vec2 &) const
CrossProduct (const Vec2 &) const
void Normalize ()

Public Attributes

x
y

Friends

class Matrix2
template<typename U >
Vec2< U > operator* (const U &, const Vec2< U > &)

Detailed Description

template<typename T>
class nux::Vec2< T >

Definition at line 37 of file Vector2.h.


Constructor & Destructor Documentation

template<typename T >
nux::Vec2< T >::Vec2 ( ) [inline]

Definition at line 76 of file Vector2.h.

  {
    x = 0;
    y = 0;
  }
template<typename T >
nux::Vec2< T >::~Vec2 ( ) [inline]

Definition at line 83 of file Vector2.h.

  {

  }
template<typename T>
nux::Vec2< T >::Vec2 ( const T &  fx,
const T &  fy 
) [inline]

Definition at line 96 of file Vector2.h.

  {
    x = fx;
    y = fy;
  }
template<typename T>
nux::Vec2< T >::Vec2 ( const Vec2< T > &  v) [inline]

Definition at line 115 of file Vector2.h.

  {
    x = v.x;
    y = v.y;
  }

Member Function Documentation

template<typename T >
T nux::Vec2< T >::CrossProduct ( const Vec2< T > &  v) const [inline]

Definition at line 243 of file Vector2.h.

  {
    T val;
    val = x * v.y - y * v.x;
    return val;
  }
template<typename T >
T nux::Vec2< T >::DotProduct ( const Vec2< T > &  v) const [inline]

Definition at line 237 of file Vector2.h.

  {
    return x * v.x + y * v.y;
  }
template<typename T >
T nux::Vec2< T >::Length ( ) const [inline]

Definition at line 231 of file Vector2.h.

  {
    return (T) sqrt (x * x + y * y);
  }
template<typename T >
void nux::Vec2< T >::Normalize ( ) [inline]

Definition at line 251 of file Vector2.h.

  {
    T l;

    l = Length();

    if (l == 0)
    {
      throw DivisionByZeroException();
    }

    x = x / l;
    y = y / l;
  }
template<typename T>
bool nux::Vec2< T >::operator!= ( const Vec2< T > &  v) const [inline]

Definition at line 142 of file Vector2.h.

  {
    return ! (*this == v);
  }
template<typename T>
Vec2< T > nux::Vec2< T >::operator* ( const Vec2< T > &  v) const [inline]

Definition at line 154 of file Vector2.h.

  {
    return Vec2<T> (x * v.x, y * v.y);
  }
template<typename T>
Vec2< T > nux::Vec2< T >::operator* ( const T &  f) const [inline]

Definition at line 207 of file Vector2.h.

  {
    return Vec2<T> (x * f, y * f);
  }
template<typename T>
Vec2< T > & nux::Vec2< T >::operator*= ( const Vec2< T > &  v) [inline]

Definition at line 172 of file Vector2.h.

  {
    x *= v.x;
    y *= v.y;
    return *this;
  }
template<typename T>
Vec2< T > nux::Vec2< T >::operator+ ( const Vec2< T > &  v) const [inline]

Definition at line 148 of file Vector2.h.

  {
    return Vec2<T> (x + v.x, y + v.y);
  }
template<typename T>
Vec2< T > & nux::Vec2< T >::operator+= ( const Vec2< T > &  v) [inline]

Definition at line 180 of file Vector2.h.

  {
    x += v.x;
    y += v.y;
    return *this;
  }
template<typename T>
Vec2< T > nux::Vec2< T >::operator- ( const Vec2< T > &  v) const [inline]

Definition at line 160 of file Vector2.h.

  {
    return Vec2<T> (x - v.x, y - v.y);
  }
template<typename T>
Vec2< T > nux::Vec2< T >::operator- ( ) const [inline]

Definition at line 166 of file Vector2.h.

  {
    return Vec2<T> (-x, -y);
  }
template<typename T>
Vec2< T > & nux::Vec2< T >::operator-= ( const Vec2< T > &  v) [inline]

Definition at line 188 of file Vector2.h.

  {
    x -= v.x;
    y -= v.y;
    return *this;
  }
template<typename T>
Vec2< T > nux::Vec2< T >::operator/ ( const T &  f) const [inline]

Definition at line 196 of file Vector2.h.

  {
    if (f == 0)
    {
      throw DivisionByZeroException();
    }

    return Vec2 (x / f, y / f);
  }
template<typename T>
Vec2< T > & nux::Vec2< T >::operator= ( const Vec2< T > &  v) [inline]

Definition at line 122 of file Vector2.h.

  {
    x = v.x;
    y = v.y;
    return *this;
  }
template<typename T>
bool nux::Vec2< T >::operator== ( const Vec2< T > &  v) const [inline]

Definition at line 130 of file Vector2.h.

  {
    if ( (x == v.x) &&
         (y == v.y) )
    {
      return true;
    }

    return false;
  }
template<typename T >
T & nux::Vec2< T >::operator[] ( int  i) [inline]

element access

Definition at line 214 of file Vector2.h.

  {
    assert (i >= 0);
    assert (i <= 1);
    return * (&x + i);
  }
template<typename T >
const T & nux::Vec2< T >::operator[] ( int  i) const [inline]

element access (const)

Definition at line 223 of file Vector2.h.

  {
    assert (i >= 0);
    assert (i <= 1);
    return * (&x + i);
  }

Friends And Related Function Documentation

template<typename T>
friend class Matrix2 [friend]

Definition at line 70 of file Vector2.h.

template<typename T>
template<typename U >
Vec2<U> operator* ( const U &  f,
const Vec2< U > &  v 
) [friend]

Definition at line 279 of file Vector2.h.

  {
    return v * f;
  }

Member Data Documentation

template<typename T>
T nux::Vec2< T >::x

Definition at line 72 of file Vector2.h.

template<typename T>
T nux::Vec2< T >::y

Definition at line 72 of file Vector2.h.


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