Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes

ml7::Vector2 Class Reference

#include <Vector2.h>

List of all members.

Public Member Functions

 Vector2 (void)
 Vector2 (const Vector2 &v)
Vector2operator= (const Vector2 &v)
void swap (Vector2 &v)
 ~Vector2 (void)
 Vector2 (const float x, const float y)
 Vector2 (const float c)
const float length () const
const float lensqr () const
const Vector2 normalized () const
const Vector2 abs () const
const float operator[] (unsigned index) const
float & operator[] (unsigned index)
const Vector2 operator- () const
const Vector2 operator+ (const Vector2 &v) const
const Vector2 operator- (const Vector2 &v) const
const Vector2 operator* (const float s) const
const Vector2 operator* (const Vector2 &v) const
const float dot (const Vector2 &v) const
const float dotsqr (const Vector2 &v) const
const Vector2 perp () const
const float perpdot (const Vector2 &v) const
const float comp (const Vector2 &v) const
const Vector2 proj (const Vector2 &v) const
const float azimuth () const
const float ccw (const ml7::Vector2 &p, const ml7::Vector2 &q)
const Vector2 x_ () const
const Vector2 _y () const
const Vector2 xx () const
const Vector2 yy () const
Vector2operator+= (const Vector2 &v)
Vector2operator-= (const Vector2 &v)
Vector2operator*= (const float s)
Vector2operator*= (const Vector2 &v)
Vector2clear ()
Vector2invert ()
Vector2normalize ()
Vector2add (const Vector2 &v, const float s)
Vector2mad (const float s, const Vector2 &v)
Vector2mul (const Vector2 &v)
const bool operator== (const Vector2 &v) const
const bool operator!= (const Vector2 &v) const
const bool operator< (const Vector2 &v) const
const bool operator> (const Vector2 &v) const
const bool operator<= (const Vector2 &v) const
const bool operator>= (const Vector2 &v) const
 operator const float *const () const
 operator float *const ()

Static Public Member Functions

static Vector2 abs1 (const Vector2 &v)
static Vector2 min2 (const Vector2 &a, const Vector2 &b)
static Vector2 max2 (const Vector2 &a, const Vector2 &b)

Public Attributes

union {
   struct {
      float   x
      float   y
   } 
   struct {
      float   u
      float   v
   } 
   struct {
      float   s
      float   t
   } 
   float   data [2]
}; 

Static Public Attributes

static const Vector2 X = Vector2( 1, 0 )
static const Vector2 Y = Vector2( 0, 1 )

Detailed Description

Represents a vector with two dimensions x and y. Used for 2d-physics and -graphics.


Constructor & Destructor Documentation

ml7::Vector2::Vector2 ( void   )  [inline]

Default constructor. Creates a new vector with x = y = 0.

ml7::Vector2::Vector2 ( const Vector2 v  )  [inline]

Copy constructor. Creates a new vector with x = v.x, y = v.y.

ml7::Vector2::~Vector2 ( void   )  [inline]

Destructor.

ml7::Vector2::Vector2 ( const float  x,
const float  y 
) [inline]

Explicit constructor with parameters for x and y.

ml7::Vector2::Vector2 ( const float  c  )  [inline, explicit]

Explicit constructor with one parameter for both components x and y.


Member Function Documentation

const Vector2 ml7::Vector2::_y (  )  const [inline]

Returns a new vector with the y component of this (x = 0).

const Vector2 ml7::Vector2::abs (  )  const [inline]

Returns this vector having positive components.

static Vector2 ml7::Vector2::abs1 ( const Vector2 v  )  [inline, static]

Returns a copy of a given vector having positive components.

Vector2& ml7::Vector2::add ( const Vector2 v,
const float  s 
) [inline]

Adds a given vector v scaled by a given scalar s to this.

const float ml7::Vector2::azimuth (  )  const

Returns the azimuth angle of this vector.

const float ml7::Vector2::ccw ( const ml7::Vector2 p,
const ml7::Vector2 q 
)

Checks whether the three given points consisting of this vector and the two given vectors are a ccw turn. In that case, the function returns a value greater than zero. A value less than 0 indicates a clockwise turn. 0 indicates that the points are collinear.

Vector2& ml7::Vector2::clear (  )  [inline]

Sets x = y = 0.

const float ml7::Vector2::comp ( const Vector2 v  )  const [inline]

Returns the scalar projection of a given vector v onto this.

const float ml7::Vector2::dot ( const Vector2 v  )  const [inline]

Returns the dot product of this and a given vector v.

const float ml7::Vector2::dotsqr ( const Vector2 v  )  const [inline]

Returns the squared dot product of this and a given vector v.

Vector2& ml7::Vector2::invert (  )  [inline]

Inverts the sign of the components of this vector.

const float ml7::Vector2::length (  )  const [inline]

Returns the magnitude of the vector.

const float ml7::Vector2::lensqr (  )  const [inline]

Returns the squared magnitude of the vector.

Vector2& ml7::Vector2::mad ( const float  s,
const Vector2 v 
) [inline]

Scales this vector by a given scalar s and then adds a given vector v to this.

static Vector2 ml7::Vector2::max2 ( const Vector2 a,
const Vector2 b 
) [inline, static]

Returns a vector having the maximum components of two given vectors.

static Vector2 ml7::Vector2::min2 ( const Vector2 a,
const Vector2 b 
) [inline, static]

Returns a vector having the minimum components of two given vectors.

Vector2& ml7::Vector2::mul ( const Vector2 v  )  [inline]

Scales this vector component-wise by a given vector v.

Vector2& ml7::Vector2::normalize (  )  [inline]

Normalizes this vector that it has a magnitude of 1.

const Vector2 ml7::Vector2::normalized (  )  const [inline]

Returns a copy of this vector normalized.

ml7::Vector2::operator const float *const (  )  const [inline]
ml7::Vector2::operator float *const (  )  [inline]
const bool ml7::Vector2::operator!= ( const Vector2 v  )  const [inline]

Checks if a given vector v and this have non-identical components.

const Vector2 ml7::Vector2::operator* ( const Vector2 v  )  const [inline]

Returns a given vector scaled component-wise by this.

const Vector2 ml7::Vector2::operator* ( const float  s  )  const [inline]

Returns a copy of this vector scaled by a given scalar s.

Vector2& ml7::Vector2::operator*= ( const Vector2 v  )  [inline]

Scales this vector component-wise by a given vector v.

Vector2& ml7::Vector2::operator*= ( const float  s  )  [inline]

Scales this vector by a given scalar s.

const Vector2 ml7::Vector2::operator+ ( const Vector2 v  )  const [inline]

Returns a given vector v added to this.

Vector2& ml7::Vector2::operator+= ( const Vector2 v  )  [inline]

Adds a given vector v to this.

const Vector2 ml7::Vector2::operator- ( const Vector2 v  )  const [inline]

Returns a given vector v subtracted from this.

const Vector2 ml7::Vector2::operator- (  )  const [inline]

Returns a copy of this vector with the components having signs flipped.

Vector2& ml7::Vector2::operator-= ( const Vector2 v  )  [inline]

Subtracts a given vector v from this.

const bool ml7::Vector2::operator< ( const Vector2 v  )  const [inline]

Checks if this vector is component-by-component less than a given vector v.

const bool ml7::Vector2::operator<= ( const Vector2 v  )  const [inline]

Checks if this vector is component-by-component less than or equal to a given vector v.

Vector2& ml7::Vector2::operator= ( const Vector2 v  )  [inline]

Copy assignment operator. Sets x = v.x and y = v.y.

const bool ml7::Vector2::operator== ( const Vector2 v  )  const [inline]

Checks if a given vector v and this have identical components.

const bool ml7::Vector2::operator> ( const Vector2 v  )  const [inline]

Checks if this vector is component-by-component greater than a given vector v.

const bool ml7::Vector2::operator>= ( const Vector2 v  )  const [inline]

Checks if this vector is component-by-component greater than or equal to a given vector v.

float& ml7::Vector2::operator[] ( unsigned  index  )  [inline]

Indexed component access.

const float ml7::Vector2::operator[] ( unsigned  index  )  const [inline]

Indexed component access.

const Vector2 ml7::Vector2::perp (  )  const [inline]

Returns the perpendicular of this vector.

const float ml7::Vector2::perpdot ( const Vector2 v  )  const [inline]

Returns the perp-dot product of this and a given vector v.

const Vector2 ml7::Vector2::proj ( const Vector2 v  )  const [inline]

Returns the vector projection of a given vector v onto this.

void ml7::Vector2::swap ( Vector2 v  )  [inline]

Swap operation. Swaps the elements of a vector v with this.

const Vector2 ml7::Vector2::x_ (  )  const [inline]

Returns a new vector with the x component of this (y = 0).

const Vector2 ml7::Vector2::xx (  )  const [inline]

Returns a new vector with all of its components set to the x value of this.

const Vector2 ml7::Vector2::yy (  )  const [inline]

Returns a new vector with all of its components set to the y value of this.


Member Data Documentation

union { ... }

Array of the two componets.

The texture coordinate s (s = u = x).

The texture coordinate t (t = v = y).

The texture coordinate u (u = s = x).

The texture coordinate v (v = t = y).

const Vector2 ml7::Vector2::X = Vector2( 1, 0 ) [static]

The vector's x value (x = u = s).

The vector's y value (y = v = t).

const Vector2 ml7::Vector2::Y = Vector2( 0, 1 ) [static]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines