7 #ifndef NAZARA_VECTOR2_HPP 8 #define NAZARA_VECTOR2_HPP 10 #include <Nazara/Core/String.hpp> 15 struct SerializationContext;
17 template<
typename T>
class Vector3;
18 template<
typename T>
class Vector4;
26 explicit Vector2(T scale);
27 Vector2(
const T vec[2]);
28 template<
typename U>
explicit Vector2(
const Vector2<U>& vec);
29 Vector2(
const Vector2& vec) =
default;
30 explicit Vector2(
const Vector3<T>& vec);
31 explicit Vector2(
const Vector4<T>& vec);
37 T
Distance(
const Vector2& vec)
const;
38 float Distancef(
const Vector2& vec)
const;
43 Vector2
GetNormal(T* length =
nullptr)
const;
51 Vector2&
Maximize(
const Vector2& vec);
52 Vector2&
Minimize(
const Vector2& vec);
56 Vector2&
Set(T X, T Y);
57 Vector2&
Set(T scale);
58 Vector2&
Set(
const T vec[2]);
59 Vector2&
Set(
const Vector2& vec);
60 Vector2&
Set(
const Vector3<T>& vec);
61 Vector2&
Set(
const Vector4<T>& vec);
62 template<
typename U> Vector2&
Set(
const Vector2<U>& vec);
69 operator const T* ()
const;
74 Vector2
operator+(
const Vector2& vec)
const;
75 Vector2
operator-(
const Vector2& vec)
const;
76 Vector2
operator*(
const Vector2& vec)
const;
78 Vector2
operator/(
const Vector2& vec)
const;
80 Vector2& operator=(
const Vector2& other) =
default;
96 static T
DotProduct(
const Vector2& vec1,
const Vector2& vec2);
97 static Vector2
Lerp(
const Vector2& from,
const Vector2& to, T interpolation);
98 static Vector2
Normalize(
const Vector2& vec);
99 static Vector2
Unit();
100 static Vector2
UnitX();
101 static Vector2
UnitY();
102 static Vector2
Zero();
107 typedef Vector2<double> Vector2d;
108 typedef Vector2<float> Vector2f;
109 typedef Vector2<int> Vector2i;
110 typedef Vector2<unsigned int> Vector2ui;
111 typedef Vector2<Int32> Vector2i32;
112 typedef Vector2<UInt32> Vector2ui32;
114 template<
typename T>
bool Serialize(SerializationContext& context,
const Vector2<T>& vector);
115 template<
typename T>
bool Unserialize(SerializationContext& context, Vector2<T>* vector);
118 template<
typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vector2<T>& vec);
125 template<
class T>
struct hash<
Nz::Vector2<T>>;
128 #include <Nazara/Math/Vector2.inl> 130 #endif // NAZARA_VECTOR2_HPP bool operator<(const Vector2 &vec) const
Compares the vector to other one.
Definition: Vector2.inl:800
bool operator<=(const Vector2 &vec) const
Compares the vector to other one.
Definition: Vector2.inl:816
Vector2 & Minimize(const Vector2 &vec)
Sets this vector's components to the minimum of its own and other components.
Definition: Vector2.inl:312
T GetLength() const
Calculates the length (magnitude) of the vector.
Definition: Vector2.inl:180
Vector2 & MakeUnit()
Makes the vector (1, 1)
Definition: Vector2.inl:237
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
bool operator==(const Vector2 &vec) const
Compares the vector to other one.
Definition: Vector2.inl:773
Vector2 & MakeUnitX()
Makes the vector (1, 0)
Definition: Vector2.inl:250
Vector2 & operator+=(const Vector2 &vec)
Adds the components of other vector to this vector.
Definition: Vector2.inl:651
bool Unserialize(SerializationContext &context, bool *value)
Unserializes a boolean.
Definition: Algorithm.inl:279
String ToString() const
Gives a string representation.
Definition: Vector2.inl:484
float Distancef(const Vector2 &vec) const
Calculates the distance between two vectors.
Definition: Vector2.inl:152
Vector2 & operator*=(const Vector2 &vec)
Multiplies the components of other vector to this vector.
Definition: Vector2.inl:683
T SquaredDistance(const Vector2 &vec) const
Calculates the squared distance between two vectors.
Definition: Vector2.inl:473
static Vector2 UnitY()
Shorthand for the vector (0, 1)
Definition: Vector2.inl:945
Vector2 operator/(const Vector2 &vec) const
Divides the components of the vector with other vector.
Definition: Vector2.inl:602
Vector2 & operator/=(const Vector2 &vec)
Multiplies the components of other vector to this vector.
Definition: Vector2.inl:718
static Vector2 Lerp(const Vector2 &from, const Vector2 &to, T interpolation)
Interpolates the vector to other one with a factor of interpolation.
Definition: Vector2.inl:880
Vector2 & MakeZero()
Makes the vector (0, 0)
Definition: Vector2.inl:276
Vector2 & Set(T X, T Y)
Sets the components of the vector.
Definition: Vector2.inl:360
static Vector2 Unit()
Shorthand for the vector (1, 1)
Definition: Vector2.inl:914
Vector2 operator*(const Vector2 &vec) const
Multiplies the components of the vector with other vector.
Definition: Vector2.inl:573
bool operator!=(const Vector2 &vec) const
Compares the vector to other one.
Definition: Vector2.inl:787
T AngleBetween(const Vector2 &vec) const
Calculates the angle between two vectors in orthonormal basis.
Definition: Vector2.inl:124
bool operator>(const Vector2 &vec) const
Compares the vector to other one.
Definition: Vector2.inl:832
T AbsDotProduct(const Vector2 &vec) const
Calculates the absolute dot (scalar) product with two vectors.
Definition: Vector2.inl:107
T GetSquaredLength() const
Calculates the squared length (magnitude) of the vector.
Definition: Vector2.inl:224
static Vector2 UnitX()
Shorthand for the vector (1, 0)
Definition: Vector2.inl:930
float GetLengthf() const
Calculates the length (magnitude) of the vector.
Definition: Vector2.inl:191
T DotProduct(const Vector2 &vec) const
Calculates the dot (scalar) product with two vectors.
Definition: Vector2.inl:167
Vector2 & MakeUnitY()
Makes the vector (0, 1)
Definition: Vector2.inl:263
Vector2 GetNormal(T *length=nullptr) const
Gets a copy normalized of the vector.
Definition: Vector2.inl:208
Vector2 & operator-=(const Vector2 &vec)
Substracts the components of other vector to this vector.
Definition: Vector2.inl:667
static Vector2 Zero()
Shorthand for the vector (0, 0)
Definition: Vector2.inl:960
bool Serialize(SerializationContext &context, bool value)
Serializes a boolean.
Definition: Algorithm.inl:214
T Distance(const Vector2 &vec) const
Calculates the distance between two vectors.
Definition: Vector2.inl:139
Vector2 & Maximize(const Vector2 &vec)
Sets this vector's components to the maximum of its own and other components.
Definition: Vector2.inl:291
const Vector2 & operator+() const
Helps to represent the sign of the vector.
Definition: Vector2.inl:523
Vector2 & Normalize(T *length=nullptr)
Normalizes the current vector.
Definition: Vector2.inl:335
Vector2 operator-() const
Negates the components of the vector.
Definition: Vector2.inl:534
bool operator>=(const Vector2 &vec) const
Compares the vector to other one.
Definition: Vector2.inl:845
Math class that represents an element of the two dimensional vector space.
Definition: Matrix4.hpp:21