renderstack::vec2 Class Reference

simple two component float vector

#include <vec2.hpp>

Public Member Functions

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

Data Fields

float x
float y

Detailed Description

Definition at line 35 of file vec2.hpp.


Constructor & Destructor Documentation

renderstack::vec2::vec2 ( float  _x = 0,
float  _y = 0 
) [inline]

Definition at line 38 of file vec2.hpp.

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


Member Function Documentation

vec2 renderstack::vec2::operator+ ( vec2 const &  v  )  const [inline]

Definition at line 44 of file vec2.hpp.

00045     {
00046         return vec2(x + v.x, y + v.y);
00047     }

vec2& renderstack::vec2::operator+= ( vec2 const &  v  )  [inline]

Definition at line 49 of file vec2.hpp.

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

vec2 renderstack::vec2::operator- ( vec2 const &  v  )  const [inline]

Definition at line 56 of file vec2.hpp.

00057     {
00058         return vec2(x - v.x, y - v.y);
00059     }

vec2& renderstack::vec2::operator-= ( vec2 const &  v  )  [inline]

Definition at line 61 of file vec2.hpp.

00062     {
00063         x -= v.x;
00064         y -= v.y;
00065         return *this;
00066     }

bool renderstack::vec2::operator== ( vec2 const &  v  )  const [inline]

Definition at line 68 of file vec2.hpp.

00069     {
00070         return 
00071             (x == v.x) && 
00072             (y == v.y);
00073     }

vec2 renderstack::vec2::operator* ( float  f  )  const [inline]

Definition at line 74 of file vec2.hpp.

00075     {
00076         return vec2(f * x, f * y);
00077     }

vec2& renderstack::vec2::operator*= ( float  f  )  [inline]

Definition at line 79 of file vec2.hpp.

00080     {
00081         x *= f;
00082         y *= f;
00083         return *this;
00084     }

vec2 renderstack::vec2::operator/ ( float  f  )  const [inline]

Definition at line 86 of file vec2.hpp.

00087     {
00088         float inv = 1.0f / f;
00089         return vec2(x * inv, y * inv);
00090     }

vec2& renderstack::vec2::operator/= ( float  f  )  [inline]

Definition at line 92 of file vec2.hpp.

00093     {
00094         float inv = 1.f / f;
00095         x *= inv; 
00096         y *= inv; 
00097         return *this;
00098     }

vec2 renderstack::vec2::operator- (  )  const [inline]

Definition at line 100 of file vec2.hpp.

00101     {
00102         return vec2(-x, -y);
00103     }

float renderstack::vec2::operator[] ( int  i  )  const [inline]

Definition at line 105 of file vec2.hpp.

00106     {
00107         return (&x)[i];
00108     }

float& renderstack::vec2::operator[] ( int  i  )  [inline]

Definition at line 110 of file vec2.hpp.

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

float renderstack::vec2::length_squared (  )  const [inline]

Definition at line 115 of file vec2.hpp.

00115 { return x * x + y * y; }

float renderstack::vec2::length (  )  const [inline]

Definition at line 116 of file vec2.hpp.

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


Field Documentation

Definition at line 118 of file vec2.hpp.

Definition at line 119 of file vec2.hpp.


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