A lot of operations based on sf::Vector2 and sf::Vector3. For specific overview, see VectorAlgebra2D.hpp and VectorAlgebra3D.hpp. More...
Classes | |
struct | thor::PolarVector2< T > |
Vector in polar coordinate system. More... | |
Typedefs | |
typedef PolarVector2< float > | thor::PolarVector2f |
Type definition for float polar vectors. | |
Functions | |
template<typename T > | |
T | thor::length (const sf::Vector2< T > &vector) |
Returns the length of the 2D vector. | |
template<typename T > | |
T | thor::squaredLength (const sf::Vector2< T > &vector) |
Returns the square of vector's length. More... | |
template<typename T > | |
void | thor::setLength (sf::Vector2< T > &vector, T newLength) |
Adapts vector so that its length is |newLength| after this operation. More... | |
template<typename T > | |
sf::Vector2< T > | thor::unitVector (const sf::Vector2< T > &vector) |
Returns a vector with same direction as the argument, but with length 1. More... | |
template<typename T > | |
T | thor::polarAngle (const sf::Vector2< T > &vector) |
Returns the polar angle. More... | |
template<typename T > | |
void | thor::setPolarAngle (sf::Vector2< T > &vector, T newAngle) |
Sets the polar angle of the specified vector. More... | |
template<typename T > | |
void | thor::rotate (sf::Vector2< T > &vector, T angle) |
Rotates the vector by the given angle (in degrees). More... | |
template<typename T > | |
sf::Vector2< T > | thor::rotatedVector (const sf::Vector2< T > &vector, T angle) |
Returns a copy of the vector, rotated by angle degrees. More... | |
template<typename T > | |
sf::Vector2< T > | thor::perpendicularVector (const sf::Vector2< T > &vector) |
Returns a perpendicular vector. More... | |
template<typename T > | |
T | thor::signedAngle (const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs) |
Computes the signed angle from lhs to rhs. More... | |
template<typename T > | |
T | thor::dotProduct (const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs) |
Computes the dot product of two 2D vectors. | |
template<typename T > | |
T | thor::crossProduct (const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs) |
Computes the cross product of two 2D vectors (Z component only). More... | |
template<typename T > | |
sf::Vector2< T > | thor::cwiseProduct (const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs) |
Returns the component-wise product of lhs and rhs. More... | |
template<typename T > | |
sf::Vector2< T > | thor::cwiseQuotient (const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs) |
Returns the component-wise quotient of lhs and rhs. More... | |
template<typename T > | |
sf::Vector2< T > | thor::projectedVector (const sf::Vector2< T > &vector, const sf::Vector2< T > &axis) |
Returns the projection of vector onto axis. More... | |
template<typename T > | |
T | thor::length (const sf::Vector3< T > &vector) |
Returns the length of the 3D vector. | |
template<typename T > | |
T | thor::squaredLength (const sf::Vector3< T > &vector) |
Returns the square of vector's length. More... | |
template<typename T > | |
sf::Vector3< T > | thor::unitVector (const sf::Vector3< T > &vector) |
Returns a vector with same direction as the argument, but with length 1. More... | |
template<typename T > | |
T | thor::polarAngle (const sf::Vector3< T > &vector) |
Returns the angle between the projection of vector onto the XY-plane and the X-axis. More... | |
template<typename T > | |
T | thor::elevationAngle (const sf::Vector3< T > &vector) |
Returns the elevation angle of vector. More... | |
template<typename T > | |
T | thor::dotProduct (const sf::Vector3< T > &lhs, const sf::Vector3< T > &rhs) |
Computes the dot product of two 3D vectors. | |
template<typename T > | |
sf::Vector3< T > | thor::crossProduct (const sf::Vector3< T > &lhs, const sf::Vector3< T > &rhs) |
Computes the cross product of two 3D vectors. | |
template<typename T > | |
sf::Vector3< T > | thor::cwiseProduct (const sf::Vector3< T > &lhs, const sf::Vector3< T > &rhs) |
Returns the component-wise product of lhs and rhs. More... | |
template<typename T > | |
sf::Vector3< T > | thor::cwiseQuotient (const sf::Vector3< T > &lhs, const sf::Vector3< T > &rhs) |
Returns the component-wise quotient of lhs and rhs. More... | |
template<typename T > | |
sf::Vector3< T > | thor::toVector3 (const sf::Vector2< T > &vector2) |
Constructs a 3D vector from a 2D vector by setting the Z component to zero. | |
template<typename T > | |
T | length (const PolarVector2< T > &vector) |
Returns the length of a polar vector. More... | |
template<typename T > | |
T | polarAngle (const PolarVector2< T > &vector) |
Returns the angle of a polar vector in degrees. More... | |
A lot of operations based on sf::Vector2 and sf::Vector3. For specific overview, see VectorAlgebra2D.hpp and VectorAlgebra3D.hpp.
T thor::crossProduct | ( | const sf::Vector2< T > & | lhs, |
const sf::Vector2< T > & | rhs | ||
) |
Computes the cross product of two 2D vectors (Z component only).
Treats the operands as 3D vectors, computes their cross product and returns the result's Z component (X and Y components are always zero).
sf::Vector3<T> thor::cwiseProduct | ( | const sf::Vector3< T > & | lhs, |
const sf::Vector3< T > & | rhs | ||
) |
Returns the component-wise product of lhs and rhs.
Computes (lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z). Component-wise multiplications are mainly used for scales.
sf::Vector2<T> thor::cwiseProduct | ( | const sf::Vector2< T > & | lhs, |
const sf::Vector2< T > & | rhs | ||
) |
Returns the component-wise product of lhs and rhs.
Computes (lhs.x*rhs.x, lhs.y*rhs.y). Component-wise multiplications are mainly used for scales.
sf::Vector3<T> thor::cwiseQuotient | ( | const sf::Vector3< T > & | lhs, |
const sf::Vector3< T > & | rhs | ||
) |
Returns the component-wise quotient of lhs and rhs.
Computes (lhs.x/rhs.x, lhs.y/rhs.y, lhs.z/rhs.z). Component-wise divisions are mainly used for scales.
sf::Vector2<T> thor::cwiseQuotient | ( | const sf::Vector2< T > & | lhs, |
const sf::Vector2< T > & | rhs | ||
) |
Returns the component-wise quotient of lhs and rhs.
Computes (lhs.x/rhs.x, lhs.y/rhs.y). Component-wise divisions are mainly used for scales.
T thor::elevationAngle | ( | const sf::Vector3< T > & | vector | ) |
Returns the elevation angle of vector.
The elevation angle is the angle between the vector and the XY-plane. It has the same sign as vector.z.
|
related |
Returns the length of a polar vector.
The returned value is vector.r.
sf::Vector2<T> thor::perpendicularVector | ( | const sf::Vector2< T > & | vector | ) |
Returns a perpendicular vector.
Returns vector turned by 90 degrees counter clockwise; (x,y) becomes (-y,x). For example, the vector (1,0) is transformed to (0,1).
T thor::polarAngle | ( | const sf::Vector3< T > & | vector | ) |
Returns the angle between the projection of vector onto the XY-plane and the X-axis.
Example: The vector (1,0,z) corresponds 0 degrees, (0,1,z) corresponds 90 degrees, where z is arbitrary.
|
related |
Returns the angle of a polar vector in degrees.
The returned value is vector.phi.
T thor::polarAngle | ( | const sf::Vector2< T > & | vector | ) |
Returns the polar angle.
The vector (1,0) corresponds 0 degrees, (0,1) corresponds 90 degrees.
sf::Vector2<T> thor::projectedVector | ( | const sf::Vector2< T > & | vector, |
const sf::Vector2< T > & | axis | ||
) |
Returns the projection of vector onto axis.
vector | Vector to project onto another. |
axis | Vector being projected onto. Need not be a unit vector, but may not have length zero. |
void thor::rotate | ( | sf::Vector2< T > & | vector, |
T | angle | ||
) |
Rotates the vector by the given angle (in degrees).
The vector (1,0) corresponds 0 degrees, (0,1) corresponds 90 degrees.
sf::Vector2<T> thor::rotatedVector | ( | const sf::Vector2< T > & | vector, |
T | angle | ||
) |
Returns a copy of the vector, rotated by angle degrees.
The vector (1,0) corresponds 0 degrees, (0,1) corresponds 90 degrees.
void thor::setLength | ( | sf::Vector2< T > & | vector, |
T | newLength | ||
) |
Adapts vector so that its length is |newLength| after this operation.
If newLength is less than zero, the vector's direction changes.
void thor::setPolarAngle | ( | sf::Vector2< T > & | vector, |
T | newAngle | ||
) |
Sets the polar angle of the specified vector.
The vector (1,0) corresponds 0 degrees, (0,1) corresponds 90 degrees.
T thor::signedAngle | ( | const sf::Vector2< T > & | lhs, |
const sf::Vector2< T > & | rhs | ||
) |
Computes the signed angle from lhs to rhs.
T thor::squaredLength | ( | const sf::Vector3< T > & | vector | ) |
Returns the square of vector's length.
Suitable for comparisons, more efficient than length().
T thor::squaredLength | ( | const sf::Vector2< T > & | vector | ) |
Returns the square of vector's length.
Suitable for comparisons, more efficient than length().
sf::Vector3<T> thor::unitVector | ( | const sf::Vector3< T > & | vector | ) |
Returns a vector with same direction as the argument, but with length 1.
sf::Vector2<T> thor::unitVector | ( | const sf::Vector2< T > & | vector | ) |
Returns a vector with same direction as the argument, but with length 1.