UGDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Static Public Member Functions | Public Attributes
ugdk::Vector2D Class Reference

#include <vector2D.h>

List of all members.

Public Member Functions

 Vector2D ()
 Initializes both fields with 0.0.
 Vector2D (double value)
 Initializes both fields with val.
 Vector2D (double _x, double _y)
 Initializes both fields with given values.
 Vector2D (const ugdk::math::Integer2D &int2d)
 Copy constructor from Integer2D.
 ~Vector2D ()
double get_x () const
double get_y () const
void set_x (double x_)
void set_y (double y_)
double NormOne () const
 Returns the norm-1 of this vector.
double Length () const
 Returns the norm-2 of this vector.
double LengthSquared () const
 Returns the norm-2 squared.
double Angle () const
 Returns the angle (in radians) of this vector.
Vector2D Normalize () const
 Returns a new vector equal to this vector normalized.
Vector2D Rotate (const double angle) const
 Returns a new vector equal to this vector rotated by "angle" (in radians) counter-clockwise.
void Mirror (const ugdk::enums::mirroraxis::MirrorAxis axis)
 Mirrors this Vector2D (in-place) by the "axis" axis. Include types.h and use "using namespace ugdk::enums".
Vector2D Mirrored (const ugdk::enums::mirroraxis::MirrorAxis axis) const
 Returns a new Vector2D, mirrored by the "axis" axis. Include types.h and use "using namespace ugdk::enums".
Vector2D Scale (const Vector2D &scale) const
 Returns a new vector which is this vector scaled coordinate by coordinate with "scale".
double length () const
 Deprecated. Use the upper case method.
double angle () const
 Deprecated. Use the upper case method.
bool operator== (const Vector2D &rhs)
 Compares this vector to the given vector, return True if they are equivalent.
Vector2Doperator+= (const Vector2D &other)
Vector2Doperator-= (const Vector2D &other)
Vector2D operator+ (const Vector2D &right) const
 Method that returns a vector equal to the sum of two others.
Vector2D operator- () const
 Method that returns a vector equal to the oposite of another.
Vector2D operator- (const Vector2D &right) const
 Method that returns a vector equal to the subtraction of two others.
Vector2D operator* (const double &scalar) const
 Method that returns a vector equal to the a vector multiplied by a scalar.
Vector2D operator/ (const double &scalar) const
 Method that returns a vector equal to the a vector multiplied by the inverse of a scalar.
double operator* (const Vector2D &right) const
 Method that returns a scalar equal to the inner product of two vectors.

Static Public Member Functions

static Vector2D Add (const Vector2D &a, const Vector2D &b)
 Static method that returns a vector equal to the sum of two others.
static Vector2D Subtract (const Vector2D &a, const Vector2D &b)
 Static method that returns a vector equal to the subtraction of two others.
static Vector2D Multiply (const Vector2D &a, const double &scalar)
 Static method that returns a vector equal to the a vector multiplied by a scalar.
static double InnerProduct (const Vector2D &a, const Vector2D &b)
 Static method that returns a scalar equal to the inner product of two vectors.
static Vector2D Normalized (Vector2D &a)
 Deprecated. Use the method function Normalize.
static Vector2D Rotate (Vector2D &a, double angle)
 Deprecated. Use the method function Rotate.

Public Attributes

union {
   struct {
      double   x
      double   y
   } 
   struct {
      double   val [2]
   } 
}; 

Constructor & Destructor Documentation

Initializes both fields with 0.0.

Create the vector (x,y) with x = 0 and y =0

ugdk::Vector2D::Vector2D ( double  value) [inline, explicit]

Initializes both fields with val.

Create the vector (x,y) with x = val and y = val being val a constant

Parameters:
valis a constant
ugdk::Vector2D::Vector2D ( double  _x,
double  _y 
) [inline]

Initializes both fields with given values.

Create the vector (x,y) with x = x-value and y = y-value

Parameters:
xis the x-value argument
yis the y-value argument

Copy constructor from Integer2D.


Member Function Documentation

static Vector2D ugdk::Vector2D::Add ( const Vector2D a,
const Vector2D b 
) [inline, static]

Static method that returns a vector equal to the sum of two others.

The sum of two vectors (x,y) (w,z) is igual to the vector (x+w, y+z)

Returns:
Sum Vector
double ugdk::Vector2D::Angle ( ) const

Returns the angle (in radians) of this vector.

Return the angle (in radians) associated to this vector

Returns:
Angle
double ugdk::Vector2D::angle ( ) const [inline]

Deprecated. Use the upper case method.

Depprecated method that returns the angle associated to a vector (x,y). Use instead Angle()

Returns:
angle
See also:
Angle()
double ugdk::Vector2D::get_x ( ) const [inline]
double ugdk::Vector2D::get_y ( ) const [inline]
static double ugdk::Vector2D::InnerProduct ( const Vector2D a,
const Vector2D b 
) [inline, static]

Static method that returns a scalar equal to the inner product of two vectors.

By definition the inner product of two vectors (x,y) (w,z) is equal to (x*w) + (y*z)

Returns:
InnerProduct
double ugdk::Vector2D::Length ( ) const

Returns the norm-2 of this vector.

The norm-2 of a vector (x,y) is sqrt( x^2 + y^2 )

Returns:
Norm-2
See also:
NormOne()
LenghtSquared()
double ugdk::Vector2D::length ( ) const [inline]

Deprecated. Use the upper case method.

Deprecated method that returns the Lenght of a vector (x,y). Use instead Lenght method

Returns:
lenght
See also:
Lenght()
double ugdk::Vector2D::LengthSquared ( ) const [inline]

Returns the norm-2 squared.

The norm-2 squared of a vector (x,y) is (x^2 + y^2)

Returns:
Norm-2 Squared
See also:
NormOne()
Lenght()

Mirrors this Vector2D (in-place) by the "axis" axis. Include types.h and use "using namespace ugdk::enums".

Parameters:
axisEither mirroraxis::HORZ, mirroraxis::VERT, mirroraxis::DIAG_UP, or mirroraxis::DIAG_DOWN.
See also:
Mirrored

Returns a new Vector2D, mirrored by the "axis" axis. Include types.h and use "using namespace ugdk::enums".

Parameters:
axisEither mirroraxis::HORZ, mirroraxis::VERT, mirroraxis::DIAG_UP, or mirroraxis::DIAG_DOWN.
See also:
Mirror
static Vector2D ugdk::Vector2D::Multiply ( const Vector2D a,
const double &  scalar 
) [inline, static]

Static method that returns a vector equal to the a vector multiplied by a scalar.

A vector (x,y) multiplied by a scalar a is equal to the vector (x * scalar, y*scalar)

Returns:
Scalar Multiplied Vector

Returns a new vector equal to this vector normalized.

The normalized vector (x,y) is (x,y) / Lenght(x,y)

Returns:
Normalized Vector
See also:
Lenght()
static Vector2D ugdk::Vector2D::Normalized ( Vector2D a) [inline, static]

Deprecated. Use the method function Normalize.

Deprecated method that returns a normalized vector of a vector (x,y). Use instead Normalize

Returns:
normalized vector
See also:
Normalize()
double ugdk::Vector2D::NormOne ( ) const

Returns the norm-1 of this vector.

The norm-1 of a vector (x,y) is |x| + |y|.

Returns:
Norm-1
See also:
Length()
Vector2D ugdk::Vector2D::operator* ( const double &  scalar) const

Method that returns a vector equal to the a vector multiplied by a scalar.

A vector (x,y) multiplied by a scalar a is equal to the vector (x * scalar, y*scalar)

Returns:
Scalar Multiplied Vector
double ugdk::Vector2D::operator* ( const Vector2D right) const

Method that returns a scalar equal to the inner product of two vectors.

By definition the inner product of two vectors (x,y) (w,z) is equal to (x*w) + (y*z)

Returns:
InnerProduct
Vector2D ugdk::Vector2D::operator+ ( const Vector2D right) const

Method that returns a vector equal to the sum of two others.

The sum of two vectors (x,y) (w,z) is igual to the vector (x+w, y+z)

Returns:
Sum Vector
Vector2D & ugdk::Vector2D::operator+= ( const Vector2D other)
Vector2D ugdk::Vector2D::operator- ( ) const

Method that returns a vector equal to the oposite of another.

The oposite of a vector (x,y) is equal to the vector (-x,-y) in this order

Returns:
Oposite Vector
Vector2D ugdk::Vector2D::operator- ( const Vector2D right) const

Method that returns a vector equal to the subtraction of two others.

The subtraction of two vectors (x,y) (z,w) is equal to the vector (x-z,y-w) in this order

Returns:
Subtract Vector
Vector2D & ugdk::Vector2D::operator-= ( const Vector2D other)
Vector2D ugdk::Vector2D::operator/ ( const double &  scalar) const

Method that returns a vector equal to the a vector multiplied by the inverse of a scalar.

A vector (x,y) multiplied by the inverse of a scalar is equal to the vector (x * 1/scalar, y * 1/scalar)

Returns:
Inverse Scalar Multiplied Vector
bool ugdk::Vector2D::operator== ( const Vector2D rhs) [inline]

Compares this vector to the given vector, return True if they are equivalent.

Two vectors are equivalent if the coordinates are equal.

Returns:
True if vectors are equivalent.
Vector2D ugdk::Vector2D::Rotate ( const double  angle) const

Returns a new vector equal to this vector rotated by "angle" (in radians) counter-clockwise.

The vector rotated of a vector (x,y) is (x * cos(angle) - y * sin(angle) , x * sin(angle) + y * cos(angle)); angle in radians

Returns:
Rotated Vector
See also:
Angle
static Vector2D ugdk::Vector2D::Rotate ( Vector2D a,
double  angle 
) [inline, static]

Deprecated. Use the method function Rotate.

Deprecated method that returns a rotated vector of a vector (x,y). Use instead Rotate

Returns:
rotated vector
See also:
Rotate
Vector2D ugdk::Vector2D::Scale ( const Vector2D scale) const

Returns a new vector which is this vector scaled coordinate by coordinate with "scale".

The resulting scaled vector is (this->x * scale.x, this->y * scale.y).

Returns:
scaled vector
void ugdk::Vector2D::set_x ( double  x_) [inline]
void ugdk::Vector2D::set_y ( double  y_) [inline]
static Vector2D ugdk::Vector2D::Subtract ( const Vector2D a,
const Vector2D b 
) [inline, static]

Static method that returns a vector equal to the subtraction of two others.

The subtraction of two vectors (x,y) (z,w) is equal to the vector (x-z,y-w) in this order

Returns:
Subtract Vector

Member Data Documentation

union { ... }

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