Horizon
|
Class VECTOR2 defines a general 2D-vector/point. More...
#include <vector2d.h>
Public Types | |
typedef VECTOR2_TRAITS< T >::extended_type | extended_type |
typedef T | coord_type |
Public Member Functions | |
VECTOR2 () | |
Construct a 2D-vector with x, y = 0. | |
VECTOR2 (T x, T y) | |
Construct a vector with given components x, y. | |
template<typename CastingType > | |
VECTOR2 (const VECTOR2< CastingType > &aVec) | |
Initializes a vector from another specialization. More... | |
template<typename CastedType > | |
VECTOR2< CastedType > | operator() () const |
Casts a vector to another specialized subclass. More... | |
T | EuclideanNorm () const |
Destructor. More... | |
extended_type | SquaredEuclideanNorm () const |
Function Squared Euclidean Norm computes the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2). More... | |
VECTOR2< T > | Perpendicular () const |
Function Perpendicular computes the perpendicular vector. More... | |
VECTOR2< T > | Resize (T aNewLength) const |
Function Resize returns a vector of the same direction, but length specified in aNewLength. More... | |
double | Angle () const |
Function Angle computes the angle of the vector. More... | |
VECTOR2< T > | Rotate (double aAngle) const |
Function Rotate rotates the vector by a given angle. More... | |
const std::string | Format () const |
Function Format returns the vector formatted as a string. More... | |
extended_type | Cross (const VECTOR2< T > &aVector) const |
Function Cross() computes cross product of self with aVector. | |
extended_type | Dot (const VECTOR2< T > &aVector) const |
Function Dot() computes dot product of self with aVector. | |
VECTOR2< T > & | operator= (const VECTOR2< T > &aVector) |
Assignment operator. | |
VECTOR2< T > | operator+ (const VECTOR2< T > &aVector) const |
Vector addition operator. | |
VECTOR2< T > | operator+ (const T &aScalar) const |
Scalar addition operator. | |
VECTOR2< T > & | operator+= (const VECTOR2< T > &aVector) |
Compound assignment operator. | |
VECTOR2< T > & | operator+= (const T &aScalar) |
Compound assignment operator. | |
VECTOR2< T > | operator- (const VECTOR2< T > &aVector) const |
Vector subtraction operator. | |
VECTOR2< T > | operator- (const T &aScalar) const |
Scalar subtraction operator. | |
VECTOR2< T > & | operator-= (const VECTOR2< T > &aVector) |
Compound assignment operator. | |
VECTOR2< T > & | operator-= (const T &aScalar) |
Compound assignment operator. | |
VECTOR2< T > | operator- () |
Negate Vector operator. | |
extended_type | operator* (const VECTOR2< T > &aVector) const |
Scalar product operator. | |
VECTOR2< T > | operator* (const T &aFactor) const |
Multiplication with a factor. | |
VECTOR2< T > | operator/ (const T &aFactor) const |
Division with a factor. | |
bool | operator== (const VECTOR2< T > &aVector) const |
Equality operator. | |
bool | operator!= (const VECTOR2< T > &aVector) const |
Not equality operator. | |
bool | operator< (const VECTOR2< T > &aVector) const |
Smaller than operator. | |
bool | operator<= (const VECTOR2< T > &aVector) const |
bool | operator> (const VECTOR2< T > &aVector) const |
Greater than operator. | |
bool | operator>= (const VECTOR2< T > &aVector) const |
Public Attributes | |
T | x |
T | y |
Static Public Attributes | |
static constexpr extended_type | ECOORD_MAX = std::numeric_limits<extended_type>::max() |
static constexpr extended_type | ECOORD_MIN = std::numeric_limits<extended_type>::min() |
Class VECTOR2 defines a general 2D-vector/point.
This class uses templates to be universal. Several operators are provided to help easy implementing of linear algebra equations.
|
inline |
Initializes a vector from another specialization.
Beware of rouding issues.
double VECTOR2< T >::Angle |
Function Angle computes the angle of the vector.
T VECTOR2< T >::EuclideanNorm |
Destructor.
Function Euclidean Norm computes the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2). It is used to calculate the length of the vector.
const std::string VECTOR2< T >::Format |
Function Format returns the vector formatted as a string.
|
inline |
Casts a vector to another specialized subclass.
Beware of rouding issues.
Function Perpendicular computes the perpendicular vector.
Function Resize returns a vector of the same direction, but length specified in aNewLength.
aNewLength | length of the rescaled vector |
Function Rotate rotates the vector by a given angle.
Rotate a VECTOR2 by aAngle.
aAngle | rotation angle in radians |
aAngle | = rotation angle in radians |
Function Squared Euclidean Norm computes the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
It is used to calculate the length of the vector.