Back to index

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

#include <Vector4.h>

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

List of all members.

Public Member Functions

 Vec4 ()
 ~Vec4 ()
 Vec4 (const T &, const T &, const T &, const T &)
 Vec4 (const Vec4< T > &)
Vec4< T > & operator= (const Vec4< T > &)
bool operator== (const Vec4< T > &) const
bool operator!= (const Vec4< T > &) const
Vec4< T > operator+ (const Vec4< T > &) const
Vec4< T > operator* (const Vec4< T > &) const
Vec4< T > operator- (const Vec4< T > &) const
Vec4< T > operator- () const
Vec4< T > & operator*= (const Vec4< T > &)
Vec4< T > & operator+= (const Vec4< T > &)
Vec4< T > & operator-= (const Vec4< T > &)
Vec4< T > operator/ (const T &) const
Vec4< T > operator* (const T &) const
Vec4< T > & operator/= (const T &)
Vec4< T > & operator*= (const T &)
T & operator[] (int i)
 element access
const T & operator[] (int i) const
 element access (const)
void divide_xyz_by_w ()

Public Attributes

x
y
z
w

Friends

template<typename U >
Vec4< U > operator* (const U &, const Vec4< U > &)

Detailed Description

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

Definition at line 30 of file Vector4.h.


Constructor & Destructor Documentation

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

Definition at line 68 of file Vector4.h.

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

Definition at line 77 of file Vector4.h.

  {

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

Definition at line 83 of file Vector4.h.

  {
    x = fx;
    y = fy;
    z = fz;
    w = fw;
  }
template<typename T>
nux::Vec4< T >::Vec4 ( const Vec4< T > &  v) [inline]

Definition at line 108 of file Vector4.h.

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

Member Function Documentation

template<typename T >
void nux::Vec4< T >::divide_xyz_by_w ( )

Definition at line 267 of file Vector4.h.

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

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

Definition at line 141 of file Vector4.h.

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

Definition at line 153 of file Vector4.h.

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

Definition at line 213 of file Vector4.h.

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

Definition at line 172 of file Vector4.h.

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

Definition at line 234 of file Vector4.h.

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

Definition at line 147 of file Vector4.h.

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

Definition at line 182 of file Vector4.h.

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

Definition at line 159 of file Vector4.h.

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

Definition at line 165 of file Vector4.h.

  {
    //Do that for Matices too
    return Vec4<T> (-x, -y, -z, -w);
  }
template<typename T>
Vec4< T > & nux::Vec4< T >::operator-= ( const Vec4< T > &  v) [inline]

Definition at line 192 of file Vector4.h.

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

Definition at line 202 of file Vector4.h.

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

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

Definition at line 219 of file Vector4.h.

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

    x = x / f;
    y = y / f;
    z = z / f;
    w = w / f;
    return *this;
  }
template<typename T>
Vec4< T > & nux::Vec4< T >::operator= ( const Vec4< T > &  v) [inline]

Definition at line 117 of file Vector4.h.

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

Definition at line 127 of file Vector4.h.

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

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

element access

Definition at line 250 of file Vector4.h.

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

element access (const)

Definition at line 259 of file Vector4.h.

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

Friends And Related Function Documentation

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

Definition at line 280 of file Vector4.h.

  {
    return v * f;
  }

Member Data Documentation

template<typename T>
T nux::Vec4< T >::w

Definition at line 63 of file Vector4.h.

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

Definition at line 63 of file Vector4.h.

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

Definition at line 63 of file Vector4.h.

template<typename T>
T nux::Vec4< T >::z

Definition at line 63 of file Vector4.h.


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