Back to index

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

#include <Vector3.h>

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

List of all members.

Public Member Functions

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

Public Attributes

x
y
z

Friends

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

Detailed Description

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

Definition at line 34 of file Vector3.h.


Constructor & Destructor Documentation

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

Definition at line 77 of file Vector3.h.

  {
    x = 0;
    y = 0;
    z = 0;
  }
template<typename T>
nux::Vec3< T >::Vec3 ( const T &  fx,
const T &  fy,
const T &  fz 
) [inline]

Definition at line 91 of file Vector3.h.

  {
    x = fx;
    y = fy;
    z = fz;
  }
template<typename T >
nux::Vec3< T >::~Vec3 ( ) [inline]

Definition at line 85 of file Vector3.h.

  {

  }
template<typename T>
nux::Vec3< T >::Vec3 ( const Vec3< T > &  v) [inline]

Definition at line 113 of file Vector3.h.

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

Member Function Documentation

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

Definition at line 276 of file Vector3.h.

  {
    return Vec3<T> (y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
  }

Here is the caller graph for this function:

template<typename T>
T nux::Vec3< T >::DotProduct ( const Vec3< T > &  v) const [inline]

Definition at line 270 of file Vector3.h.

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

Definition at line 258 of file Vector3.h.

  {
    return sqrt (x * x + y * y + z * z);
  }
template<typename T >
T nux::Vec3< T >::LengthSquared ( ) const [inline]

Definition at line 264 of file Vector3.h.

  {
    return (x * x + y * y + z * z);
  }

Here is the caller graph for this function:

template<typename T >
void nux::Vec3< T >::Normalize ( ) [inline]

Definition at line 282 of file Vector3.h.

  {
    T l;
    l = Length();

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

    x = x / l;
    y = y / l;
    z = z / l;
  }

Here is the caller graph for this function:

template<typename T>
bool nux::Vec3< T >::operator!= ( const Vec3< T > &  v) const [inline]

Definition at line 143 of file Vector3.h.

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

Definition at line 155 of file Vector3.h.

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

Definition at line 211 of file Vector3.h.

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

Definition at line 173 of file Vector3.h.

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

Definition at line 231 of file Vector3.h.

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

Definition at line 149 of file Vector3.h.

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

Definition at line 182 of file Vector3.h.

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

Definition at line 161 of file Vector3.h.

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

Definition at line 167 of file Vector3.h.

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

Definition at line 191 of file Vector3.h.

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

Definition at line 200 of file Vector3.h.

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

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

Definition at line 217 of file Vector3.h.

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

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

Definition at line 121 of file Vector3.h.

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

Definition at line 130 of file Vector3.h.

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

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

element access

Definition at line 241 of file Vector3.h.

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

element access (const)

Definition at line 250 of file Vector3.h.

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

Friends And Related Function Documentation

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

Definition at line 317 of file Vector3.h.

  {
    return v * f;
  }

Member Data Documentation

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

Definition at line 73 of file Vector3.h.

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

Definition at line 73 of file Vector3.h.

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

Definition at line 73 of file Vector3.h.


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