xyginext  0.2.0
Second generation of xygine game creation framework
Functions
xy::Util::Vector Namespace Reference

Vector math utility functions. More...

Functions

static float dot (const sf::Vector2f &lv, const sf::Vector2f &rv)
 Calculates the dot product of 2 vectors.
 
static sf::Vector2f normalise (sf::Vector2f source)
 Returns a given vector with its length normalized to 1.
 
static float lengthSquared (const sf::Vector2f &source)
 Returns length of a vector squared. More...
 
static float length (const sf::Vector2f &source)
 Returns length of a given vector. More...
 
static sf::Vector2f reflect (const sf::Vector2f &velocity, const sf::Vector2f &normal)
 Reflects a velocity vector about a given normal.
 
static sf::Vector2f rotate (const sf::Vector2f &v, float degrees)
 Rotates a vector (not very accurately) More...
 
static float rotation (const sf::Vector2f v)
 Gets the rotation (in degrees) of a vector.
 
template<typename T >
static sf::Vector2< T > vec2FromString (const std::string &str)
 Converts a comma delimited string to vector 2.
 
template<typename T >
sf::Vector2< T > operator* (const sf::Vector2< T > &l, const sf::Vector2< T > &r)
 

Detailed Description

Vector math utility functions.

Function Documentation

◆ length()

static float xy::Util::Vector::length ( const sf::Vector2f &  source)
inlinestatic

Returns length of a given vector.

If comparing the length of two vectors it is mroe efficient to use the squared lengths

See also
lengthSquared

◆ lengthSquared()

static float xy::Util::Vector::lengthSquared ( const sf::Vector2f &  source)
inlinestatic

Returns length of a vector squared.

When comparing the length of two vectors it is less expensive to compare the squared lengths, which will return the same result

◆ rotate()

static sf::Vector2f xy::Util::Vector::rotate ( const sf::Vector2f &  v,
float  degrees 
)
inlinestatic

Rotates a vector (not very accurately)

Parameters
vVector to rotate
degreesNumber of degrees to rotate vector
Returns
Rotated vector