UGDK
0.5.0
|
#include <ugdk/math/vector2D.h>
Public Member Functions | |
Vector2D () | |
Initializes both fields with 0.0. More... | |
Vector2D (double value) | |
Initializes both fields with val. More... | |
Vector2D (double _x, double _y) | |
Initializes both fields with given values. More... | |
Vector2D (const math::Integer2D &int2d) | |
Copy constructor from Integer2D. More... | |
~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. More... | |
double | Length () const |
Returns the norm-2 of this vector. More... | |
double | LengthSquared () const |
Returns the norm-2 squared. More... | |
double | Angle () const |
Returns the angle (in radians) of this vector. More... | |
Vector2D | Normalize () const |
Returns a new vector equal to this vector normalized. More... | |
Vector2D | Rotate (double angle) const |
Returns a new vector equal to this vector rotated by "angle" (in radians) counter-clockwise. More... | |
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". More... | |
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". More... | |
Vector2D | Scale (const Vector2D &scale) const |
Returns a new vector which is this vector scaled coordinate by coordinate with "scale". More... | |
void | Divide (const Vector2D ÷r) |
In-place integer division, coordinate by coordinate. More... | |
Vector2D | Divided (const Vector2D ÷r) const |
Returns a new Integer2D equal to this divided coordinate by coordinate by "multiplier". More... | |
double | length () const |
Deprecated. Use the upper case method. More... | |
double | angle () const |
Deprecated. Use the upper case method. More... | |
bool | operator== (const Vector2D &rhs) |
Compares this vector to the given vector, return True if they are equivalent. More... | |
Vector2D & | operator+= (const Vector2D &other) |
Vector2D & | operator-= (const Vector2D &other) |
Vector2D & | operator*= (double other) |
Vector2D | operator+ (const Vector2D &right) const |
Method that returns a vector equal to the sum of two others. More... | |
Vector2D | operator- () const |
Method that returns a vector equal to the oposite of another. More... | |
Vector2D | operator- (const Vector2D &right) const |
Method that returns a vector equal to the subtraction of two others. More... | |
Vector2D | operator* (double scalar) const |
Method that returns a vector equal to the a vector multiplied by a scalar. More... | |
Vector2D | operator/ (double scalar) const |
Method that returns a vector equal to the a vector multiplied by the inverse of a scalar. More... | |
double | operator* (const Vector2D &right) const |
Method that returns a scalar equal to the inner product of two vectors. More... | |
operator std::array< double, 2 > () const | |
operator std::pair< double, double > () const | |
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. More... | |
static Vector2D | Subtract (const Vector2D &a, const Vector2D &b) |
Static method that returns a vector equal to the subtraction of two others. More... | |
static Vector2D | Multiply (const Vector2D &a, double scalar) |
Static method that returns a vector equal to the a vector multiplied by a scalar. More... | |
static double | InnerProduct (const Vector2D &a, const Vector2D &b) |
Static method that returns a scalar equal to the inner product of two vectors. More... | |
static Vector2D | Normalized (Vector2D &a) |
Deprecated. Use the method function Normalize. More... | |
static Vector2D | Rotate (Vector2D &a, double angle) |
Deprecated. Use the method function Rotate. More... | |
Public Attributes | |
union { | |
struct { | |
double x | |
double y | |
} | |
struct { | |
double val [2] | |
} | |
}; | |
|
inline |
Initializes both fields with 0.0.
Create the vector (x,y) with x = 0 and y =0
|
inlineexplicit |
Initializes both fields with val.
Create the vector (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 vector (x,y) with x = x-value and y = y-value
x | is the x-value argument |
y | is the y-value argument |
ugdk::math::Vector2D::Vector2D | ( | const math::Integer2D & | int2d | ) |
Copy constructor from Integer2D.
|
inline |
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)
double ugdk::math::Vector2D::Angle | ( | ) | const |
Returns the angle (in radians) of this vector.
Return the angle (in radians) associated to this vector
|
inline |
void ugdk::math::Vector2D::Divide | ( | const Vector2D & | divider | ) |
|
inline |
|
inline |
|
inlinestatic |
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)
double ugdk::math::Vector2D::Length | ( | ) | const |
Returns the norm-2 of this vector.
The norm-2 of a vector (x,y) is sqrt( x^2 + y^2 )
|
inline |
Deprecated. Use the upper case method.
Deprecated method that returns the Lenght of a vector (x,y). Use instead Lenght method
|
inline |
Returns the norm-2 squared.
The norm-2 squared of a vector (x,y) is (x^2 + y^2)
void ugdk::math::Vector2D::Mirror | ( | const ugdk::enums::mirroraxis::MirrorAxis | axis | ) |
Vector2D ugdk::math::Vector2D::Mirrored | ( | const ugdk::enums::mirroraxis::MirrorAxis | axis | ) | const |
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)
Vector2D ugdk::math::Vector2D::Normalize | ( | ) | const |
Returns a new vector equal to this vector normalized.
The normalized vector (x,y) is (x,y) / Lenght(x,y)
Deprecated. Use the method function Normalize.
Deprecated method that returns a normalized vector of a vector (x,y). Use instead Normalize
double ugdk::math::Vector2D::NormOne | ( | ) | const |
Returns the norm-1 of this vector.
The norm-1 of a vector (x,y) is |x| + |y|.
|
inline |
|
inline |
Vector2D ugdk::math::Vector2D::operator* | ( | 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)
double ugdk::math::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)
Vector2D& ugdk::math::Vector2D::operator*= | ( | double | other | ) |
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)
Vector2D ugdk::math::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
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
Vector2D ugdk::math::Vector2D::operator/ | ( | 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)
|
inline |
Compares this vector to the given vector, return True if they are equivalent.
Two vectors are equivalent if the coordinates are equal.
Vector2D ugdk::math::Vector2D::Rotate | ( | 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
Deprecated. Use the method function Rotate.
Deprecated method that returns a rotated vector of a vector (x,y). Use instead Rotate
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).
|
inline |
|
inline |
|
inlinestatic |
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
union { ... } |
double ugdk::math::Vector2D::val[2] |
double ugdk::math::Vector2D::x |
double ugdk::math::Vector2D::y |