UGDK
0.5.0
|
#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 ¢er) |
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 ¢er) 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 ÷r) |
In-place integer division, coordinate by coordinate. More... | |
Integer2D | Divided (const Integer2D ÷r) 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... | |
Integer2D & | operator+= (const Integer2D &other) |
Integer2D & | operator-= (const Integer2D &other) |
Integer2D & | operator*= (int scalar) |
Integer2D & | operator/= (int scalar) |
Integer2D & | operator%= (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] | |
} | |
}; | |
|
inline |
Initializes both fields with 0.
Create the integer (x,y) with x = 0 and y =0
|
inlineexplicit |
Initializes both fields with val.
Create the integer (x,y) with x = val and y = val being val a constant
val | is a constant |
|
inline |
Initializes both fields with given values.
Create the integer (x,y) with x = x-value and y = y-value
x | is the x-value argument |
y | is the y-value argument |
|
explicit |
Copy constructor from ugdk::math::Vector2D.
|
inline |
double ugdk::math::Integer2D::Angle | ( | ) | const |
Returns the angle (in radians) of this integer.
Return the angle (in radians) associated to this integer
void ugdk::math::Integer2D::Divide | ( | const Integer2D & | divider | ) |
|
inline |
|
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 )
|
inline |
Returns the norm-2 squared.
The norm-2 squared of a integer (x,y) is (x^2 + y^2)
void ugdk::math::Integer2D::Mirror | ( | const ugdk::enums::mirroraxis::MirrorAxis | mirror | ) |
Integer2D ugdk::math::Integer2D::Mirrored | ( | const ugdk::enums::mirroraxis::MirrorAxis | mirror | ) | const |
void ugdk::math::Integer2D::Mod | ( | const Integer2D & | divisor | ) |
In-place remainder (coordinate by coordinate) of integer division by "divisor".
void ugdk::math::Integer2D::Multiply | ( | const Integer2D & | multiplier | ) |
In-place integer multiplication, coordinate by coordinate.
int ugdk::math::Integer2D::NormOne | ( | ) | const |
Returns the norm-1 of this integer.
The norm-1 of a integer (x,y) is |x| + |y|.
|
inline |
True when operator== is false.
Integer2D ugdk::math::Integer2D::operator% | ( | int | scalar | ) | const |
Remainder of integer division by "scalar" in each coordinate.
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)
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)
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)
Integer2D& ugdk::math::Integer2D::operator*= | ( | int | scalar | ) |
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)
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
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
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)
Integer2D& ugdk::math::Integer2D::operator/= | ( | int | scalar | ) |
|
inline |
Checks if their coordinates are equal, coordinate by coordinate.
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 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 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 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
|
inline |
|
inline |
union { ... } |
int ugdk::math::Integer2D::val[2] |
int ugdk::math::Integer2D::x |
int ugdk::math::Integer2D::y |