Bromeon
Functions
Vectors/VectorAlgebra2D.hpp File Reference

Algebraic operations on two-dimensional vectors (dot product, vector length and angles, ...) More...

Go to the source code of this file.

Functions

template<typename T >
thor::Length (const sf::Vector2< T > &vector)
 Returns the length of the 2D vector.
template<typename T >
thor::SquaredLength (const sf::Vector2< T > &vector)
 Returns the square of vector's length.
template<typename T >
void thor::SetLength (sf::Vector2< T > &vector, T newLength)
 Adapts vector so that its length is |newLength| after this operation.
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.
template<typename T >
thor::PolarAngle (const sf::Vector2< T > &vector)
 Returns the polar angle.
template<typename T >
void thor::SetPolarAngle (sf::Vector2< T > &vector, T newAngle)
 Sets the polar angle of the specified vector.
template<typename T >
void thor::Rotate (sf::Vector2< T > &vector, T angle)
 Rotates the vector by the given angle (in degrees).
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.
template<typename T >
sf::Vector2< T > thor::PerpendicularVector (const sf::Vector2< T > &vector)
 Returns a perpendicular vector.
template<typename T >
thor::Angle (const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs)
 Computes the signed angle from lhs to rhs.
template<typename T >
thor::DotProduct (const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs)
 Computes the dot product of two 2D vectors.
template<typename T >
sf::Vector3< T > thor::CrossProduct (const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs)
 Computes the cross product of two 2D vectors.
template<typename T >
sf::Vector2< T > thor::ComponentwiseProduct (const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs)
 Returns the component-wise product of lhs and rhs.
template<typename T >
sf::Vector2< T > thor::ComponentwiseQuotient (const sf::Vector2< T > &lhs, const sf::Vector2< T > &rhs)
 Returns the component-wise quotient of lhs and rhs.

Detailed Description

Algebraic operations on two-dimensional vectors (dot product, vector length and angles, ...)

Here is an overview over the functionality:

Operation Translation Scale Rotation
Get v Length(v) PolarAngle(v)
Set, absolute v = w SetLength(v,l) SetPolarAngle(v,a)
Set, relative v += w v *= l Rotate(v,a)
Copy, relative v + w v * l RotatedVector(v,a)

Other functions:

DotProduct(v,w) UnitVector(v) SquaredLength(v)
CrossProduct(v,w) PerpendicularVector(v) Angle(v,w)
ComponentwiseProduct(v,w) ComponentwiseQuotient(v,w)