Go to the documentation of this file.
12 #define PI_NUMBER 3.14159265359
41 return this->x == other.
x && this->y == other.
y;
106 template<
typename T2>
112 template<
typename T2>
120 template<
typename T2>
126 template<
typename T2>
129 return std::sqrt(std::pow(this->x - o.
x, 2) + std::pow(this->y - o.
y, 2));
134 float dot = this->x * o.
x + this->y * o.
y;
135 float det = this->x * o.
y - this->y * o.
x;
136 return (std::atan2(det, dot) * (180.0f /
PI_NUMBER));
141 return std::sqrt(std::pow(this->x, 2) + std::pow(this->y, 2));
164 return Vector2<T>(this->x / mag, this->y / mag);
169 return (point *
this) / std::pow(this->
magnitude(), 2) *
this;
187 s <<
"Vector2<" <<
typeid(T).name() <<
">("<< v.
x <<
", " << v.
y <<
")";
bool operator==(const Vector2< T > &other) const
Definition: Vector2.hpp:39
Vector2< T > projection(const Vector2< T > &point) const
Definition: Vector2.hpp:167
A Vector2 data type. (templated to allow any kind of vector2)
Definition: Vector2.hpp:18
Vector2< unsigned > Vector2u
Definition: Vector2.hpp:179
Vector2< T > & operator+=(const Vector2< T2 > &vec)
Definition: Vector2.hpp:50
Vector2< T > operator/(const Vector2< T2 > &b) const
Definition: Vector2.hpp:107
Vector2< T > operator/(T2 b) const
Definition: Vector2.hpp:121
bool operator!=(const Vector2< T > &other) const
Definition: Vector2.hpp:44
T x
The x value of the vector.
Definition: Vector2.hpp:22
~Vector2()=default
A default destructor.
Vector2< T > operator+(const Vector2< T2 > &vec) const
Definition: Vector2.hpp:58
A Two-dimensionnal Vector data type.
Definition: Vector2.hpp:15
Definition: AnimationsComponent.cpp:9
Vector2(T _x, T _y)
Create a new vector2 representing a specific coordinate.
Definition: Vector2.hpp:32
Vector2< T > operator*(T2 d) const
Definition: Vector2.hpp:87
double distance(const Vector2< T2 > &o) const
Definition: Vector2.hpp:127
Vector2< int > Vector2i
Definition: Vector2.hpp:180
Vector2< T > operator-(const Vector2< T2 > &vec) const
Definition: Vector2.hpp:72
Vector2()
Create a new nil vector2.
Definition: Vector2.hpp:27
std::ostream & operator<<(std::ostream &s, const BBM::Vector2< T > &v)
Definition: Vector2.hpp:185
Vector2< T > normalize()
Definition: Vector2.hpp:144
Vector2< T > & operator*=(T2 d)
Definition: Vector2.hpp:79
Vector2< T > & operator-=(const Vector2< T2 > &vec)
Definition: Vector2.hpp:64
Vector2< T > operator/=(T2 b)
Definition: Vector2.hpp:113
T y
The y value of the vector.
Definition: Vector2.hpp:24
double angle(const Vector2< T > &o) const
Definition: Vector2.hpp:132
Vector2< T > normalized() const
Definition: Vector2.hpp:158
Vector2< T > operator/=(const Vector2< T2 > &b)
Definition: Vector2.hpp:99
#define PI_NUMBER
Definition: Vector2.hpp:12
double magnitude() const
Definition: Vector2.hpp:139
Vector2< float > Vector2f
Definition: Vector2.hpp:178
Vector2< T > operator*(const Vector2< T2 > &b) const
Definition: Vector2.hpp:93