UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ugdk::math::Integer2D Class Reference

#include <ugdk/math/integer2D.h>

Public Member Functions

 Integer2D ()
 Initializes both fields with 0. More...
 
 Integer2D (int val)
 Initializes both fields with val. More...
 
 Integer2D (int _x, int _y)
 Initializes both fields with given values. More...
 
 Integer2D (const ugdk::math::Vector2D &vec2d)
 Copy constructor from ugdk::math::Vector2D. More...
 
 ~Integer2D ()
 
int get_x () const
 
int get_y () const
 
void set_x (int x_)
 
void set_y (int y_)
 
int NormOne () const
 Returns the norm-1 of this integer. More...
 
double Length () const
 Returns the norm-2 of this integer. More...
 
double LengthSquared () const
 Returns the norm-2 squared. More...
 
double Angle () const
 Returns the angle (in radians) of this integer. More...
 
void Rotate (RotDeg rotdeg)
 Returns a new integer equal to this integer rotated by "angle" (in radians) counter-clockwise. More...
 
void Rotate (RotDeg rotdeg, const Integer2D &center)
 Returns a new integer equal to this integer rotated by "angle" (in radians) counter-clockwise. More...
 
Integer2D Rotated (RotDeg rotdeg) const
 Returns a new integer equal to this integer rotated by "angle" (in radians) counter-clockwise. More...
 
Integer2D Rotated (RotDeg rotdeg, const Integer2D &center) const
 Returns a new integer equal to this integer rotated by "angle" (in radians) counter-clockwise. More...
 
void Mirror (const ugdk::enums::mirroraxis::MirrorAxis mirror)
 Mirrors this Integer2D (in-place) by the "axis" axis. Include types.h and use "using namespace ugdk::enums". More...
 
Integer2D Mirrored (const ugdk::enums::mirroraxis::MirrorAxis mirror) const
 Returns a new Integer2D, mirrored by the "axis" axis. Include types.h and use "using namespace ugdk::enums". More...
 
void Multiply (const Integer2D &multiplier)
 In-place integer multiplication, coordinate by coordinate. More...
 
Integer2D Multiplied (const Integer2D &multiplier) const
 Returns a new Integer2D equal to this multiplied coordinate by coordinate by "multiplier". More...
 
void Divide (const Integer2D &divider)
 In-place integer division, coordinate by coordinate. More...
 
Integer2D Divided (const Integer2D &divider) const
 Returns a new Integer2D equal to this divided coordinate by coordinate by "multiplier". More...
 
void Scale (const Integer2D &multiplier, const Integer2D &divisor)
 Multiplies in-place by "multiplier", and then divides by "divisor". More...
 
Integer2D Scaled (const Integer2D &multiplier, const Integer2D &divisor) const
 Returns a new Integer2D, multiplied by "multiplier", and divided by "divisor". More...
 
void Mod (const Integer2D &divisor)
 In-place remainder (coordinate by coordinate) of integer division by "divisor". More...
 
Integer2D Remainder (const Integer2D &divisor) const
 Returns a new Integer2D that is equal to the remainder of the integer division by "divisor". More...
 
Integer2Doperator+= (const Integer2D &other)
 
Integer2Doperator-= (const Integer2D &other)
 
Integer2Doperator*= (int scalar)
 
Integer2Doperator/= (int scalar)
 
Integer2Doperator%= (int scalar)
 
Integer2D operator+ (const Integer2D &right) const
 Method that returns a integer equal to the sum of two others. More...
 
Integer2D operator- () const
 Method that returns a integer equal to the oposite of another. More...
 
Integer2D operator- (const Integer2D &right) const
 Method that returns a integer equal to the subtraction of two others. More...
 
Integer2D operator* (int scalar) const
 Method that returns a integer equal to the a integer multiplied by a int. More...
 
Vector2D operator* (double scalar) const
 Method that returns a vector equal to the a integer multiplied by a double. More...
 
Integer2D operator/ (int scalar) const
 Method that returns a integer equal to the a integer multiplied by the inverse of a scalar. More...
 
Integer2D operator% (int scalar) const
 Remainder of integer division by "scalar" in each coordinate. More...
 
int operator* (const Integer2D &right) const
 Method that returns a scalar equal to the inner product of two vectors. More...
 
Integer2D operator% (const Integer2D &right) const
 Remainder of integer division by "scalar" coordinate by coordinate. More...
 
bool operator== (const Integer2D &right) const
 Checks if their coordinates are equal, coordinate by coordinate. More...
 
bool operator!= (const Integer2D &right) const
 True when operator== is false. More...
 

Public Attributes

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

Constructor & Destructor Documentation

ugdk::math::Integer2D::Integer2D ( )
inline

Initializes both fields with 0.

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

ugdk::math::Integer2D::Integer2D ( int  val)
inlineexplicit

Initializes both fields with val.

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

Parameters
valis a constant
ugdk::math::Integer2D::Integer2D ( int  _x,
int  _y 
)
inline

Initializes both fields with given values.

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

Parameters
xis the x-value argument
yis the y-value argument
ugdk::math::Integer2D::Integer2D ( const ugdk::math::Vector2D vec2d)
explicit

Copy constructor from ugdk::math::Vector2D.

ugdk::math::Integer2D::~Integer2D ( )
inline

Member Function Documentation

double ugdk::math::Integer2D::Angle ( ) const

Returns the angle (in radians) of this integer.

Return the angle (in radians) associated to this integer

Returns
Angle
void ugdk::math::Integer2D::Divide ( const Integer2D divider)

In-place integer division, coordinate by coordinate.

See also
Divided
Scale
Integer2D ugdk::math::Integer2D::Divided ( const Integer2D divider) const

Returns a new Integer2D equal to this divided coordinate by coordinate by "multiplier".

See also
Divide
Scale
int ugdk::math::Integer2D::get_x ( ) const
inline
int ugdk::math::Integer2D::get_y ( ) const
inline
double ugdk::math::Integer2D::Length ( ) const

Returns the norm-2 of this integer.

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

Returns
Norm-2
See also
NormOne()
LenghtSquared()
double ugdk::math::Integer2D::LengthSquared ( ) const
inline

Returns the norm-2 squared.

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

Returns
Norm-2 Squared
See also
NormOne()
Lenght()
void ugdk::math::Integer2D::Mirror ( const ugdk::enums::mirroraxis::MirrorAxis  mirror)

Mirrors this Integer2D (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
Integer2D ugdk::math::Integer2D::Mirrored ( const ugdk::enums::mirroraxis::MirrorAxis  mirror) const

Returns a new Integer2D, 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
void ugdk::math::Integer2D::Mod ( const Integer2D divisor)

In-place remainder (coordinate by coordinate) of integer division by "divisor".

See also
Remainder
Integer2D ugdk::math::Integer2D::Multiplied ( const Integer2D multiplier) const

Returns a new Integer2D equal to this multiplied coordinate by coordinate by "multiplier".

See also
Multiply
Scaled
void ugdk::math::Integer2D::Multiply ( const Integer2D multiplier)

In-place integer multiplication, coordinate by coordinate.

See also
Multiplied
Scale
int ugdk::math::Integer2D::NormOne ( ) const

Returns the norm-1 of this integer.

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

Returns
Norm-1
See also
Length()
bool ugdk::math::Integer2D::operator!= ( const Integer2D right) const
inline

True when operator== is false.

Integer2D ugdk::math::Integer2D::operator% ( int  scalar) const

Remainder of integer division by "scalar" in each coordinate.

Integer2D ugdk::math::Integer2D::operator% ( const Integer2D right) const

Remainder of integer division by "scalar" coordinate by coordinate.

Integer2D& ugdk::math::Integer2D::operator%= ( int  scalar)
Integer2D ugdk::math::Integer2D::operator* ( int  scalar) const

Method that returns a integer equal to the a integer multiplied by a int.

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

Returns
Scalar Multiplied Integer
Vector2D ugdk::math::Integer2D::operator* ( double  scalar) const

Method that returns a vector equal to the a integer multiplied by a double.

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

Returns
Scalar Multiplied Vector
int ugdk::math::Integer2D::operator* ( const Integer2D 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
Integer2D& ugdk::math::Integer2D::operator*= ( int  scalar)
Integer2D ugdk::math::Integer2D::operator+ ( const Integer2D right) const

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

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

Returns
Sum Integer
Integer2D& ugdk::math::Integer2D::operator+= ( const Integer2D other)
Integer2D ugdk::math::Integer2D::operator- ( ) const

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

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

Returns
Oposite Integer
Integer2D ugdk::math::Integer2D::operator- ( const Integer2D right) const

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

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

Returns
Subtract Integer
Integer2D& ugdk::math::Integer2D::operator-= ( const Integer2D other)
Integer2D ugdk::math::Integer2D::operator/ ( int  scalar) const

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

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

Returns
Inverse Scalar Multiplied Integer
Integer2D& ugdk::math::Integer2D::operator/= ( int  scalar)
bool ugdk::math::Integer2D::operator== ( const Integer2D right) const
inline

Checks if their coordinates are equal, coordinate by coordinate.

Integer2D ugdk::math::Integer2D::Remainder ( const Integer2D divisor) const

Returns a new Integer2D that is equal to the remainder of the integer division by "divisor".

See also
Mod
void ugdk::math::Integer2D::Rotate ( RotDeg  rotdeg)

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

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

Returns
Rotated Integer
See also
Angle
void ugdk::math::Integer2D::Rotate ( RotDeg  rotdeg,
const Integer2D center 
)
inline

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

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

Returns
Rotated Integer
See also
Angle
Integer2D ugdk::math::Integer2D::Rotated ( RotDeg  rotdeg) const

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

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

Returns
Rotated Integer
See also
Angle
Integer2D ugdk::math::Integer2D::Rotated ( RotDeg  rotdeg,
const Integer2D center 
) const
inline

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

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

Returns
Rotated Integer
See also
Angle
void ugdk::math::Integer2D::Scale ( const Integer2D multiplier,
const Integer2D divisor 
)

Multiplies in-place by "multiplier", and then divides by "divisor".

See also
Scaled
Multiply
Divide
Integer2D ugdk::math::Integer2D::Scaled ( const Integer2D multiplier,
const Integer2D divisor 
) const

Returns a new Integer2D, multiplied by "multiplier", and divided by "divisor".

See also
Scale
Multiply
Divide
void ugdk::math::Integer2D::set_x ( int  x_)
inline
void ugdk::math::Integer2D::set_y ( int  y_)
inline

Member Data Documentation

union { ... }
int ugdk::math::Integer2D::val[2]
int ugdk::math::Integer2D::x
int ugdk::math::Integer2D::y

The documentation for this class was generated from the following file: