7 #ifndef NAZARA_VECTOR3_HPP 8 #define NAZARA_VECTOR3_HPP 10 #include <Nazara/Core/String.hpp> 15 struct SerializationContext;
17 template<
typename T>
class Vector2;
18 template<
typename T>
class Vector4;
25 Vector3(T X, T Y, T Z);
26 Vector3(T X,
const Vector2<T>& vec);
27 explicit Vector3(T scale);
28 Vector3(
const T vec[3]);
29 Vector3(
const Vector2<T>& vec, T Z = 0.0);
30 template<
typename U>
explicit Vector3(
const Vector3<U>& vec);
31 Vector3(
const Vector3& vec) =
default;
32 explicit Vector3(
const Vector4<T>& vec);
40 T
Distance(
const Vector3& vec)
const;
41 float Distancef(
const Vector3& vec)
const;
46 Vector3
GetNormal(T* length =
nullptr)
const;
61 Vector3&
Maximize(
const Vector3& vec);
62 Vector3&
Minimize(
const Vector3& vec);
66 Vector3&
Set(T X, T Y, T Z);
67 Vector3&
Set(T X,
const Vector2<T>& vec);
68 Vector3&
Set(T scale);
69 Vector3&
Set(
const T vec[3]);
70 Vector3&
Set(
const Vector2<T>& vec, T Z = 0.0);
71 Vector3&
Set(
const Vector3<T>& vec);
72 template<
typename U> Vector3&
Set(
const Vector3<U>& vec);
73 Vector3&
Set(
const Vector4<T>& vec);
80 operator const T* ()
const;
85 Vector3
operator+(
const Vector3& vec)
const;
86 Vector3
operator-(
const Vector3& vec)
const;
87 Vector3
operator*(
const Vector3& vec)
const;
89 Vector3
operator/(
const Vector3& vec)
const;
91 Vector3& operator=(
const Vector3& vec) =
default;
102 bool operator<(
const Vector3& vec)
const;
104 bool operator>(
const Vector3& vec)
const;
108 static Vector3
CrossProduct(
const Vector3& vec1,
const Vector3& vec2);
109 static T
DotProduct(
const Vector3& vec1,
const Vector3& vec2);
110 static T
Distance(
const Vector3& vec1,
const Vector3& vec2);
111 static float Distancef(
const Vector3& vec1,
const Vector3& vec2);
112 static Vector3
Down();
114 static Vector3
Left();
115 static Vector3
Lerp(
const Vector3& from,
const Vector3& to, T interpolation);
116 static Vector3
Normalize(
const Vector3& vec);
117 static Vector3
Right();
119 static Vector3
Unit();
120 static Vector3
UnitX();
121 static Vector3
UnitY();
122 static Vector3
UnitZ();
124 static Vector3
Zero();
129 typedef Vector3<double> Vector3d;
130 typedef Vector3<float> Vector3f;
131 typedef Vector3<int> Vector3i;
132 typedef Vector3<unsigned int> Vector3ui;
133 typedef Vector3<Int32> Vector3i32;
134 typedef Vector3<UInt32> Vector3ui32;
136 template<
typename T>
bool Serialize(SerializationContext& context,
const Vector3<T>& vector);
137 template<
typename T>
bool Unserialize(SerializationContext& context, Vector3<T>* vector);
140 template<
typename T> std::ostream& operator<<(std::ostream& out, const Nz::Vector3<T>& vec);
147 template<
class T>
struct hash<
Nz::Vector3<T>>;
150 #include <Nazara/Math/Vector3.inl> 152 #endif // NAZARA_VECTOR3_HPP static Vector3 Right()
Shorthand for the vector (1, 0, 0)
Definition: Vector3.inl:1139
Vector3 GetNormal(T *length=nullptr) const
Gets a copy normalized of the vector.
Definition: Vector3.inl:240
Vector3 & MakeUnitY()
Makes the vector (0, 1, 0)
Definition: Vector3.inl:351
TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Vector3 & Minimize(const Vector3 &vec)
Sets this vector's components to the minimum of its own and other components.
Definition: Vector3.inl:424
float Distancef(const Vector3 &vec) const
Calculates the distance between two vectors.
Definition: Vector3.inl:188
bool operator>(const Vector3 &vec) const
Compares the vector to other one.
Definition: Vector3.inl:952
Vector3 CrossProduct(const Vector3 &vec) const
Calculates the cross (scalar) product with two vectors.
Definition: Vector3.inl:162
Vector3 & operator/=(const Vector3 &vec)
Multiplies the components of other vector to this vector.
Definition: Vector3.inl:835
String ToString() const
Gives a string representation.
Definition: Vector3.inl:612
Vector3 & operator*=(const Vector3 &vec)
Multiplies the components of other vector to this vector.
Definition: Vector3.inl:800
bool Unserialize(SerializationContext &context, bool *value)
Unserializes a boolean.
Definition: Algorithm.inl:279
Vector3 & MakeRight()
Makes the vector (1, 0, 0)
Definition: Vector3.inl:315
T SquaredDistance(const Vector3 &vec) const
Calculates the squared distance between two vectors.
Definition: Vector3.inl:602
Vector3 & MakeBackward()
Makes the vector (0, 0, 1)
Definition: Vector3.inl:267
T AngleBetween(const Vector3 &vec) const
Calculates the angle between two vectors in orthonormal basis.
Definition: Vector3.inl:134
Vector3 & MakeZero()
Makes the vector (0, 0, 0)
Definition: Vector3.inl:387
Vector3 & MakeDown()
Makes the vector (0, -1, 0)
Definition: Vector3.inl:279
Vector3 & MakeLeft()
Makes the vector (-1, 0, 0)
Definition: Vector3.inl:303
static Vector3 Up()
Shorthand for the vector (0, 1, 0)
Definition: Vector3.inl:1229
bool operator>=(const Vector3 &vec) const
Compares the vector to other one.
Definition: Vector3.inl:964
static Vector3 UnitY()
Shorthand for the vector (0, 1, 0)
Definition: Vector3.inl:1199
bool operator<=(const Vector3 &vec) const
Compares the vector to other one.
Definition: Vector3.inl:932
Vector3 operator*(const Vector3 &vec) const
Multiplies the components of the vector with other vector.
Definition: Vector3.inl:694
T GetLength() const
Calculates the length (magnitude) of the vector.
Definition: Vector3.inl:214
static Vector3 Backward()
Shorthand for the vector (0, 0, 1)
Definition: Vector3.inl:1006
static Vector3 Forward()
Shorthand for the vector (0, 0, -1)
Definition: Vector3.inl:1070
bool operator<(const Vector3 &vec) const
Compares the vector to other one.
Definition: Vector3.inl:912
static Vector3 Unit()
Shorthand for the vector (1, 1, 1)
Definition: Vector3.inl:1169
Vector3 & Normalize(T *length=nullptr)
Normalizes the current vector.
Definition: Vector3.inl:449
bool operator==(const Vector3 &vec) const
Compares the vector to other one.
Definition: Vector3.inl:886
Vector3 & Set(T X, T Y, T Z)
Sets the components of the vector.
Definition: Vector3.inl:475
Vector3 & MakeUnitX()
Makes the vector (1, 0, 0)
Definition: Vector3.inl:339
Vector3 & MakeUp()
Makes the vector (0, 1, 0)
Definition: Vector3.inl:375
T AbsDotProduct(const Vector3 &vec) const
Calculates the absolute dot (scalar) product with two vectors.
Definition: Vector3.inl:116
Vector3 & MakeUnitZ()
Makes the vector (0, 0, 1)
Definition: Vector3.inl:363
Vector3 & Maximize(const Vector3 &vec)
Sets this vector's components to the maximum of its own and other components.
Definition: Vector3.inl:401
float GetLengthf() const
Calculates the length (magnitude) of the vector.
Definition: Vector3.inl:224
static Vector3 Left()
Shorthand for the vector (-1, 0, 0)
Definition: Vector3.inl:1085
Vector3 & MakeUnit()
Makes the vector (1, 1, 1)
Definition: Vector3.inl:327
T Distance(const Vector3 &vec) const
Calculates the distance between two vectors.
Definition: Vector3.inl:176
bool Serialize(SerializationContext &context, bool value)
Serializes a boolean.
Definition: Algorithm.inl:214
T DotProduct(const Vector3 &vec) const
Calculates the dot (scalar) product with two vectors.
Definition: Vector3.inl:202
static Vector3 UnitZ()
Shorthand for the vector (0, 0, 1)
Definition: Vector3.inl:1214
T GetSquaredLength() const
Calculates the squared length (magnitude) of the vector.
Definition: Vector3.inl:255
Vector3 operator-() const
Negates the components of the vector.
Definition: Vector3.inl:658
static Vector3 Zero()
Shorthand for the vector (0, 0, 0)
Definition: Vector3.inl:1244
static Vector3 Lerp(const Vector3 &from, const Vector3 &to, T interpolation)
Interpolates the vector to other one with a factor of interpolation.
Definition: Vector3.inl:1106
Vector3 operator/(const Vector3 &vec) const
Divides the components of the vector with other vector.
Definition: Vector3.inl:721
static Vector3 Down()
Shorthand for the vector (0, -1, 0)
Definition: Vector3.inl:1055
bool operator!=(const Vector3 &vec) const
Compares the vector to other one.
Definition: Vector3.inl:900
Math class that represents an element of the three dimensional vector space.
Definition: Matrix4.hpp:22
Vector3 & operator-=(const Vector3 &vec)
Substracts the components of other vector to this vector.
Definition: Vector3.inl:784
static Vector3 UnitX()
Shorthand for the vector (1, 0, 0)
Definition: Vector3.inl:1184
Vector3 & operator+=(const Vector3 &vec)
Adds the components of other vector to this vector.
Definition: Vector3.inl:768
Vector3 & MakeForward()
Makes the vector (0, 0, -1)
Definition: Vector3.inl:291
const Vector3 & operator+() const
Helps to represent the sign of the vector.
Definition: Vector3.inl:648