123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /*
- * Author: Patrick-Christopher Mattulat
- * Company: Lynar Studios
- * E-Mail: webmaster@lynarstudios.com
- * Created: 2022-08-05
- * Changed: 2022-08-05
- *
- * */
- #include <ls-math/vector/Vector2.hpp>
- #include <math.h>
- ls::math::vector::Vector2::Vector2(const ls::math::core::type::vector2_component &_x, const ls::math::core::type::vector2_component &_y)
- {
- this->components[0] = _x;
- this->components[1] = _y;
- }
- ls::math::vector::Vector2 ls::math::vector::Vector2::operator+(ls::math::vector::Vector2 _vector)
- {
- ls::math::vector::Vector2 calculatedVector{0, 0};
- calculatedVector.setX(this->components[0] + _vector.getX());
- calculatedVector.setY(this->components[1] + _vector.getY());
- return calculatedVector;
- }
- ls::math::vector::Vector2 ls::math::vector::Vector2::operator-(ls::math::vector::Vector2 _vector)
- {
- ls::math::vector::Vector2 calculatedVector{0, 0};
- calculatedVector.setX(this->components[0] - _vector.getX());
- calculatedVector.setY(this->components[1] - _vector.getY());
- return calculatedVector;
- }
- ls::math::core::type::vector_scalar ls::math::vector::Vector2::operator*(ls::math::vector::Vector2 _vector)
- {
- return this->components[0] * _vector.getX() + this->components[1] * _vector.getY();
- }
- ls::math::vector::Vector2 ls::math::vector::Vector2::operator*(double _value)
- {
- ls::math::vector::Vector2 calculatedVector{0, 0};
- calculatedVector.setX(components[0] * _value);
- calculatedVector.setY(components[1] * _value);
- return calculatedVector;
- }
- bool ls::math::vector::Vector2::operator==(const ls::math::vector::Vector2 &_vector)
- {
- return this->components[0] == _vector.components[0] && this->components[1] == _vector.components[1];
- }
- bool ls::math::vector::Vector2::operator!=(const ls::math::vector::Vector2 &_vector)
- {
- return this->components[0] != _vector.components[0] || this->components[1] != _vector.components[1];
- }
- double ls::math::vector::Vector2::getLength()
- {
- return sqrt(this->components[0] * this->components[0] + this->components[1] * this->components[1]);
- }
- ls::math::core::type::vector2_component ls::math::vector::Vector2::getX()
- {
- return this->components[0];
- }
- ls::math::core::type::vector2_component ls::math::vector::Vector2::getY()
- {
- return this->components[1];
- }
- void ls::math::vector::Vector2::setX(const ls::math::core::type::vector2_component &_value)
- {
- this->components[0] = _value;
- }
- void ls::math::vector::Vector2::setY(const ls::math::core::type::vector2_component &_value)
- {
- this->components[1] = _value;
- }
|