|
@@ -36,9 +36,9 @@ ls::math::vector::Vector2 ls::math::vector::Vector2::operator*(double _value)
|
|
return ls::math::vector::Vector2{components[0] * _value, components[1] * _value};
|
|
return ls::math::vector::Vector2{components[0] * _value, components[1] * _value};
|
|
}
|
|
}
|
|
|
|
|
|
-ls::math::vector::Vector2 ls::math::vector::Vector2::operator/(double _value)
|
|
|
|
|
|
+ls::math::vector::Vector2 ls::math::vector::Vector2::operator/(double _divisor)
|
|
{
|
|
{
|
|
- return ls::math::vector::Vector2{this->components[0] / _value, this->components[1] / _value};
|
|
|
|
|
|
+ return ls::math::vector::Vector2::_operatorDivision(this->components[0], this->components[1], _divisor);
|
|
}
|
|
}
|
|
|
|
|
|
bool ls::math::vector::Vector2::operator==(const ls::math::vector::Vector2 &_vector)
|
|
bool ls::math::vector::Vector2::operator==(const ls::math::vector::Vector2 &_vector)
|
|
@@ -53,7 +53,7 @@ bool ls::math::vector::Vector2::operator!=(const ls::math::vector::Vector2 &_vec
|
|
|
|
|
|
double ls::math::vector::Vector2::getLength()
|
|
double ls::math::vector::Vector2::getLength()
|
|
{
|
|
{
|
|
- return sqrt(this->components[0] * this->components[0] + this->components[1] * this->components[1]);
|
|
|
|
|
|
+ return ls::math::vector::Vector2::_getLength(this->components[0], this->components[1]);
|
|
}
|
|
}
|
|
|
|
|
|
ls::math::core::type::vector2_component ls::math::vector::Vector2::getX()
|
|
ls::math::core::type::vector2_component ls::math::vector::Vector2::getX()
|
|
@@ -66,6 +66,12 @@ ls::math::core::type::vector2_component ls::math::vector::Vector2::getY()
|
|
return this->components[1];
|
|
return this->components[1];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ls::math::vector::Vector2 ls::math::vector::Vector2::normalize()
|
|
|
|
+{
|
|
|
|
+ double length = ls::math::vector::Vector2::_getLength(this->components[0], this->components[1]);
|
|
|
|
+ return ls::math::vector::Vector2::_operatorDivision(this->components[0], this->components[1], length);
|
|
|
|
+}
|
|
|
|
+
|
|
void ls::math::vector::Vector2::setX(const ls::math::core::type::vector2_component &_value)
|
|
void ls::math::vector::Vector2::setX(const ls::math::core::type::vector2_component &_value)
|
|
{
|
|
{
|
|
this->components[0] = _value;
|
|
this->components[0] = _value;
|
|
@@ -75,3 +81,13 @@ void ls::math::vector::Vector2::setY(const ls::math::core::type::vector2_compone
|
|
{
|
|
{
|
|
this->components[1] = _value;
|
|
this->components[1] = _value;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+double ls::math::vector::Vector2::_getLength(const ls::math::core::type::vector2_component& _x, const ls::math::core::type::vector2_component& _y)
|
|
|
|
+{
|
|
|
|
+ return sqrt(_x * _x + _y * _y);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+ls::math::vector::Vector2 ls::math::vector::Vector2::_operatorDivision(const ls::math::core::type::vector2_component &_x, const ls::math::core::type::vector2_component &_y, double _divisor)
|
|
|
|
+{
|
|
|
|
+ return ls::math::vector::Vector2{_x / _divisor, _y / _divisor};
|
|
|
|
+}
|