## class osg::Vec2

> General purpose float pair, uses include representation of texture coordinates.

### Public Fields

float _v[2]

### Public Methods

Vec2()
Vec2(float x, float y)
inline bool operator == (const Vec2& v) const
inline bool operator != (const Vec2& v) const
inline bool operator < (const Vec2& v) const
inline float* ptr()
inline const float* ptr() const
inline void set( float x, float y )
inline float& operator [] (int i)
inline float operator [] (int i) const
inline float& x()
inline float& y()
inline float x() const
inline float y() const
inline bool valid() const
inline bool isNaN() const
inline float operator * (const Vec2& rhs) const
  dot product
inline const Vec2 operator * (float rhs) const
  multiply by scalar
inline Vec2& operator *= (float rhs)
  unary multiply by scalar
inline const Vec2 operator / (float rhs) const
  divide by scalar
inline Vec2& operator /= (float rhs)
  unary divide by scalar
inline const Vec2 operator + (const Vec2& rhs) const
  binary vector add
inline Vec2& operator += (const Vec2& rhs)
  unary vector add.
inline const Vec2 operator - (const Vec2& rhs) const
  binary vector subtract
inline Vec2& operator -= (const Vec2& rhs)
  unary vector subtract
inline const Vec2 operator - () const
  negation operator.
inline float length() const
  Length of the vector = sqrt( vec .
inline float length2( void ) const
  Length squared of the vector = vec .
inline float normalize()
  normalize the vector so that it has length unity returns the previous length of the vector

## Documentation

> General purpose float pair, uses include representation of texture coordinates. No support yet added for float * Vec2 - is it necessary? Need to define a non-member non-friend operator* etc. BTW: Vec2 * float is okay

`Vec2()`

`Vec2(float x, float y)`

`float _v[2]`

`inline bool operator == (const Vec2& v) const`

`inline bool operator != (const Vec2& v) const`

`inline bool operator < (const Vec2& v) const`

`inline float* ptr()`

`inline const float* ptr() const`

`inline void set( float x, float y )`

`inline float& operator [] (int i)`

`inline float operator [] (int i) const`

`inline float& x()`

`inline float& y()`

`inline float x() const`

`inline float y() const`

`inline bool valid() const`

`inline bool isNaN() const`

`inline float operator * (const Vec2& rhs) const`
  dot product

`inline const Vec2 operator * (float rhs) const`
  multiply by scalar

`inline Vec2& operator *= (float rhs)`
  unary multiply by scalar

`inline const Vec2 operator / (float rhs) const`
  divide by scalar

`inline Vec2& operator /= (float rhs)`
  unary divide by scalar

`inline const Vec2 operator + (const Vec2& rhs) const`
  binary vector add

`inline Vec2& operator += (const Vec2& rhs)`
  unary vector add. Slightly more efficient because no temporary intermediate object.

`inline const Vec2 operator - (const Vec2& rhs) const`
  binary vector subtract

`inline Vec2& operator -= (const Vec2& rhs)`
  unary vector subtract

`inline const Vec2 operator - () const`
  negation operator. Returns the negative of the Vec2

`inline float length() const`
  Length of the vector = sqrt( vec . vec )

`inline float length2( void ) const`
  Length squared of the vector = vec . vec

`inline float normalize()`
  normalize the vector so that it has length unity returns the previous length of the vector

This class has no child classes.

Friends:
  inline std::ostream& operator << (std::ostream& output, const Vec2& vec)

Alphabetic index HTML hierarchy of classes or Java

This page was generated with the help of DOC++.