43 #ifndef THOR_VECTORALGEBRA2D_HPP
44 #define THOR_VECTORALGEBRA2D_HPP
48 #include <SFML/System/Vector2.hpp>
62 T
length(
const sf::Vector2<T>& vector);
73 void setLength(sf::Vector2<T>& vector, T newLength);
78 sf::Vector2<T>
unitVector(
const sf::Vector2<T>& vector);
95 void rotate(sf::Vector2<T>& vector, T angle);
100 sf::Vector2<T>
rotatedVector(
const sf::Vector2<T>& vector, T angle);
105 template <
typename T>
115 template <
typename T>
116 T
signedAngle(
const sf::Vector2<T>& lhs,
const sf::Vector2<T>& rhs);
120 template <
typename T>
121 T
dotProduct(
const sf::Vector2<T>& lhs,
const sf::Vector2<T>& rhs);
126 template <
typename T>
127 T
crossProduct(
const sf::Vector2<T>& lhs,
const sf::Vector2<T>& rhs);
131 template <
typename T>
132 sf::Vector2<T>
cwiseProduct(
const sf::Vector2<T>& lhs,
const sf::Vector2<T>& rhs);
137 template <
typename T>
138 sf::Vector2<T>
cwiseQuotient(
const sf::Vector2<T>& lhs,
const sf::Vector2<T>& rhs);
143 template <
typename T>
144 sf::Vector2<T>
projectedVector(
const sf::Vector2<T>& vector,
const sf::Vector2<T>& axis);
150 #include <Thor/Vectors/Detail/VectorAlgebra2D.inl>
151 #endif // THOR_VECTORALGEBRA2D_HPP
T polarAngle(const sf::Vector2< T > &vector)
Returns the polar angle.
T dotProduct(const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs)
Computes the dot product of two 2D vectors.
void setLength(sf::Vector2< T > &vector, T newLength)
Adapts vector so that its length is |newLength| after this operation.
sf::Vector2< T > rotatedVector(const sf::Vector2< T > &vector, T angle)
Returns a copy of the vector, rotated by angle degrees.
void rotate(sf::Vector2< T > &vector, T angle)
Rotates the vector by the given angle (in degrees).
Definition: AnimationMap.hpp:42
void setPolarAngle(sf::Vector2< T > &vector, T newAngle)
Sets the polar angle of the specified vector.
Class template thor::TrigonometricTraits and some trigonometry-related functions and constants...
T squaredLength(const sf::Vector2< T > &vector)
Returns the square of vector's length.
sf::Vector2< T > perpendicularVector(const sf::Vector2< T > &vector)
Returns a perpendicular vector.
T signedAngle(const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs)
Computes the signed angle from lhs to rhs.
sf::Vector2< T > cwiseProduct(const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs)
Returns the component-wise product of lhs and rhs.
sf::Vector2< T > cwiseQuotient(const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs)
Returns the component-wise quotient of lhs and rhs.
T length(const sf::Vector2< T > &vector)
Returns the length of the 2D vector.
sf::Vector2< T > projectedVector(const sf::Vector2< T > &vector, const sf::Vector2< T > &axis)
Returns the projection of vector onto axis.
sf::Vector2< T > unitVector(const sf::Vector2< T > &vector)
Returns a vector with same direction as the argument, but with length 1.
T crossProduct(const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs)
Computes the cross product of two 2D vectors (Z component only).