mesh3d::vec3 Class Reference

simple three component float vector

#include <vec3.h>

Public Member Functions

 vec3 (float _x=0, float _y=0, float _z=0)
vec3 operator+ (vec3 const &v) const
vec3operator+= (vec3 const &v)
vec3 operator- (vec3 const &v) const
vec3operator-= (vec3 const &v)
bool operator== (vec3 const &v) const
vec3 operator* (float f) const
vec3operator*= (float f)
vec3 operator/ (float f) const
vec3operator/= (float f)
vec3 operator- () const
float operator[] (int i) const
float & operator[] (int i)
float length_squared () const
float length () const

Data Fields

float x
float y
float z

Detailed Description

Definition at line 35 of file vec3.h.


Constructor & Destructor Documentation

mesh3d::vec3::vec3 ( float  _x = 0,
float  _y = 0,
float  _z = 0 
) [inline]

Definition at line 38 of file vec3.h.

00039     :   x(_x)
00040     ,   y(_y)
00041     ,   z(_z)
00042     {
00043     }


Member Function Documentation

vec3 mesh3d::vec3::operator+ ( vec3 const &  v  )  const [inline]

Definition at line 45 of file vec3.h.

00046     {
00047         return vec3(x + v.x, y + v.y, z + v.z);
00048     }

vec3& mesh3d::vec3::operator+= ( vec3 const &  v  )  [inline]

Definition at line 50 of file vec3.h.

00051     {
00052         x += v.x;
00053         y += v.y;
00054         z += v.z;
00055         return *this;
00056     }

vec3 mesh3d::vec3::operator- ( vec3 const &  v  )  const [inline]

Definition at line 58 of file vec3.h.

00059     {
00060         return vec3(x - v.x, y - v.y, z - v.z);
00061     }

vec3& mesh3d::vec3::operator-= ( vec3 const &  v  )  [inline]

Definition at line 63 of file vec3.h.

00064     {
00065         x -= v.x;
00066         y -= v.y;
00067         z -= v.z;
00068         return *this;
00069     }

bool mesh3d::vec3::operator== ( vec3 const &  v  )  const [inline]

Definition at line 71 of file vec3.h.

00072     {
00073         return 
00074             (x == v.x) && 
00075             (y == v.y) && 
00076             (z == v.z);
00077     }

vec3 mesh3d::vec3::operator* ( float  f  )  const [inline]

Definition at line 78 of file vec3.h.

00079     {
00080         return vec3(f * x, f * y, f * z);
00081     }

vec3& mesh3d::vec3::operator*= ( float  f  )  [inline]

Definition at line 83 of file vec3.h.

00084     {
00085         x *= f;
00086         y *= f;
00087         z *= f;
00088         return *this;
00089     }

vec3 mesh3d::vec3::operator/ ( float  f  )  const [inline]

Definition at line 91 of file vec3.h.

00092     {
00093         float inv = 1.0f / f;
00094         return vec3(x * inv, y * inv, z * inv);
00095     }

vec3& mesh3d::vec3::operator/= ( float  f  )  [inline]

Definition at line 97 of file vec3.h.

00098     {
00099         float inv = 1.f / f;
00100         x *= inv; 
00101         y *= inv; 
00102         z *= inv;
00103         return *this;
00104     }

vec3 mesh3d::vec3::operator- (  )  const [inline]

Definition at line 106 of file vec3.h.

00107     {
00108         return vec3(-x, -y, -z);
00109     }

float mesh3d::vec3::operator[] ( int  i  )  const [inline]

Definition at line 111 of file vec3.h.

00112     {
00113         return (&x)[i];
00114     }

float& mesh3d::vec3::operator[] ( int  i  )  [inline]

Definition at line 116 of file vec3.h.

00117     {
00118         return (&x)[i];
00119     }

float mesh3d::vec3::length_squared (  )  const [inline]

Definition at line 121 of file vec3.h.

00121 { return x * x + y * y + z * z; }

float mesh3d::vec3::length (  )  const [inline]

Definition at line 122 of file vec3.h.

00122 { return std::sqrt(length_squared()); }


Field Documentation

Definition at line 124 of file vec3.h.

Definition at line 125 of file vec3.h.

Definition at line 126 of file vec3.h.


The documentation for this class was generated from the following file:
Generated on Sun Apr 11 12:23:11 2010 for RenderStack by  doxygen 1.6.3