Base Framework
Public Member Functions | Protected Attributes | Related Functions | List of all members
Vector2D< TYPE > Class Template Reference

Two-dimensional vector. More...

#include <base/math/Vector2D.h>

Public Member Functions

 Vector2D () noexcept
 
 Vector2D (const TYPE &x, const TYPE &y) noexcept
 
 Vector2D (const Vector2D &copy) noexcept
 
Vector2Doperator= (const Vector2D &assign) noexcept
 
TYPE getSqrModulus () const noexcept
 
TYPE getModulus () const noexcept
 
TYPE getAngle () const noexcept
 
TYPE getX () const noexcept
 
TYPE getY () const noexcept
 
void setX (const TYPE &x) noexcept
 
void setY (const TYPE &y) noexcept
 
Vector2DzeroAdjust (const TYPE &zero) noexcept
 
bool isZero () const noexcept
 
bool isProper () const noexcept
 
bool isOrthogonal (const Vector2D &value) const noexcept
 
bool isParallel (const Vector2D &value) const noexcept
 
Vector2D plus () const noexcept
 
Vector2D minus () const noexcept
 
Vector2Dnegate () noexcept
 
Vector2Dadd (const Vector2D &value) noexcept
 
Vector2Dsubtract (const Vector2D &value) noexcept
 
Vector2Dmultiply (const TYPE &value) noexcept
 
Vector2Ddivide (const TYPE &value) noexcept
 
TYPE dot (const Vector2D &value) const noexcept
 
TYPE determinant (const Vector2D &value) const noexcept
 
TYPE getAngle (const Vector2D &value) const noexcept
 
Vector2D getProjection (const Vector2D &value) const noexcept
 
bool operator== (const Vector2D &value) const noexcept
 
Vector2Doperator+= (const Vector2D &value) noexcept
 
Vector2Doperator-= (const Vector2D &value) noexcept
 
Vector2Doperator*= (const TYPE &value) noexcept
 
Vector2Doperator/= (const TYPE &value) noexcept
 
Vector2D operator+ () const noexcept
 
Vector2D operator- () const noexcept
 

Protected Attributes

TYPE x = 0
 
TYPE y = 0
 

Related Functions

(Note that these are not member functions.)

template<class TYPE >
Vector2D< TYPE > operator+ (const Vector2D< TYPE > &left, const Vector2D< TYPE > &right) noexcept
 
template<class TYPE >
Vector2D< TYPE > operator- (const Vector2D< TYPE > &left, const Vector2D< TYPE > &right) noexcept
 
template<class TYPE >
Vector2D< TYPE > operator* (const Vector2D< TYPE > &left, const TYPE &right) noexcept
 
template<class TYPE >
Vector2D< TYPE > operator* (const TYPE &left, const Vector2D< TYPE > &right) noexcept
 
template<class TYPE >
Vector2D< TYPE > operator/ (const Vector2D< TYPE > &left, const TYPE &right) noexcept
 
template<class TYPE >
TYPE dot (const Vector2D< TYPE > &left, const Vector2D< TYPE > &right) noexcept
 
template<class TYPE >
TYPE determinant (const Vector2D< TYPE > &left, const Vector2D< TYPE > &right) noexcept
 
template<class TYPE >
FormatOutputStreamoperator<< (FormatOutputStream &stream, const Vector2D< TYPE > &value)
 

Detailed Description

template<class TYPE>
class Vector2D< TYPE >

Two-dimensional vector.

A two-dimensional vector represented by X and Y coordinates.

Version
1.1

Constructor & Destructor Documentation

◆ Vector2D() [1/3]

template<class TYPE >
Vector2D< TYPE >::Vector2D ( )
inlinenoexcept

Initializes vector as the origin (0,0).

◆ Vector2D() [2/3]

template<class TYPE >
Vector2D< TYPE >::Vector2D ( const TYPE &  x,
const TYPE &  y 
)
inlinenoexcept

Initializes vector from the specified coordinates.

Parameters
xThe desired X coordinate.
yThe desired Y coordinate.

◆ Vector2D() [3/3]

template<class TYPE >
Vector2D< TYPE >::Vector2D ( const Vector2D< TYPE > &  copy)
inlinenoexcept

Initializes vector by copying from the specified vector.

Parameters
copyThe desired vector.

Member Function Documentation

◆ add()

template<class TYPE >
Vector2D& Vector2D< TYPE >::add ( const Vector2D< TYPE > &  value)
inlinenoexcept

Adds the specified vector to this vector.

◆ determinant()

template<class TYPE >
TYPE Vector2D< TYPE >::determinant ( const Vector2D< TYPE > &  value) const
inlinenoexcept

Returns the determinant of this vector and the specified vector.

◆ divide()

template<class TYPE >
Vector2D& Vector2D< TYPE >::divide ( const TYPE &  value)
inlinenoexcept

Divides this vector with the specified value.

◆ dot()

template<class TYPE >
TYPE Vector2D< TYPE >::dot ( const Vector2D< TYPE > &  value) const
inlinenoexcept

Returns the dot product of this vector and the specified vector.

◆ getAngle() [1/2]

template<class TYPE >
TYPE Vector2D< TYPE >::getAngle ( ) const
inlinenoexcept

Returns the angle of the vector.

◆ getAngle() [2/2]

template<class TYPE >
TYPE Vector2D< TYPE >::getAngle ( const Vector2D< TYPE > &  value) const
inlinenoexcept

Returns the angle between this vector and the specified vector.

◆ getModulus()

template<class TYPE >
TYPE Vector2D< TYPE >::getModulus ( ) const
inlinenoexcept

Returns the modulus of the vector.

◆ getProjection()

template<class TYPE >
Vector2D Vector2D< TYPE >::getProjection ( const Vector2D< TYPE > &  value) const
inlinenoexcept

Returns the projection of this vector onto the specified vector.

◆ getSqrModulus()

template<class TYPE >
TYPE Vector2D< TYPE >::getSqrModulus ( ) const
inlinenoexcept

Returns the square of the modulus of the vector.

◆ getX()

template<class TYPE >
TYPE Vector2D< TYPE >::getX ( ) const
inlinenoexcept

Returns the X coordinate.

◆ getY()

template<class TYPE >
TYPE Vector2D< TYPE >::getY ( ) const
inlinenoexcept

Returns the Y coordinate.

◆ isOrthogonal()

template<class TYPE >
bool Vector2D< TYPE >::isOrthogonal ( const Vector2D< TYPE > &  value) const
inlinenoexcept

Returns true if this vector is orthogonal with the specified vector.

◆ isParallel()

template<class TYPE >
bool Vector2D< TYPE >::isParallel ( const Vector2D< TYPE > &  value) const
inlinenoexcept

Returns true if this vector is parallel with the specified vector.

◆ isProper()

template<class TYPE >
bool Vector2D< TYPE >::isProper ( ) const
inlinenoexcept

Returns true if the length of this vector is greater zero.

◆ isZero()

template<class TYPE >
bool Vector2D< TYPE >::isZero ( ) const
inlinenoexcept

Returns true if the length of this vector is zero.

◆ minus()

template<class TYPE >
Vector2D Vector2D< TYPE >::minus ( ) const
inlinenoexcept

Unary minus.

◆ multiply()

template<class TYPE >
Vector2D& Vector2D< TYPE >::multiply ( const TYPE &  value)
inlinenoexcept

Multiplies this vector with the specified value.

◆ negate()

template<class TYPE >
Vector2D& Vector2D< TYPE >::negate ( )
inlinenoexcept

Negates this vector.

◆ operator*=()

template<class TYPE >
Vector2D& Vector2D< TYPE >::operator*= ( const TYPE &  value)
inlinenoexcept

Multiplies this vector with the specified value.

Parameters
valueThe multiplicator.

◆ operator+()

template<class TYPE >
Vector2D Vector2D< TYPE >::operator+ ( ) const
inlinenoexcept

Unary plus.

◆ operator+=()

template<class TYPE >
Vector2D& Vector2D< TYPE >::operator+= ( const Vector2D< TYPE > &  value)
inlinenoexcept

Adds the specified vector from this vector.

Parameters
valueThe value to be added.

◆ operator-()

template<class TYPE >
Vector2D Vector2D< TYPE >::operator- ( ) const
inlinenoexcept

Unary minus.

◆ operator-=()

template<class TYPE >
Vector2D& Vector2D< TYPE >::operator-= ( const Vector2D< TYPE > &  value)
inlinenoexcept

Subtracts the specified vector from this vector.

Parameters
valueThe value to be subtracted.

◆ operator/=()

template<class TYPE >
Vector2D& Vector2D< TYPE >::operator/= ( const TYPE &  value)
inlinenoexcept

Divides this vector with the specified value.

Parameters
valueThe divisor.

◆ operator=()

template<class TYPE >
Vector2D& Vector2D< TYPE >::operator= ( const Vector2D< TYPE > &  assign)
inlinenoexcept

Assignment of this vector from vector.

◆ operator==()

template<class TYPE >
bool Vector2D< TYPE >::operator== ( const Vector2D< TYPE > &  value) const
inlinenoexcept

Returns true if the vectors are equal.

Parameters
vectorVector to be compared.

◆ plus()

template<class TYPE >
Vector2D Vector2D< TYPE >::plus ( ) const
inlinenoexcept

Unary plus.

◆ setX()

template<class TYPE >
void Vector2D< TYPE >::setX ( const TYPE &  x)
inlinenoexcept

Sets the X coordinate.

Parameters
xThe desired X coordinate.

◆ setY()

template<class TYPE >
void Vector2D< TYPE >::setY ( const TYPE &  y)
inlinenoexcept

Sets the Y coordinate.

Parameters
yThe desired Y coordinate.

◆ subtract()

template<class TYPE >
Vector2D& Vector2D< TYPE >::subtract ( const Vector2D< TYPE > &  value)
inlinenoexcept

Subtracts the specified vector from this vector.

◆ zeroAdjust()

template<class TYPE >
Vector2D& Vector2D< TYPE >::zeroAdjust ( const TYPE &  zero)
inlinenoexcept

Sets values less than the specified value to zero.

Friends And Related Function Documentation

◆ determinant()

template<class TYPE >
TYPE determinant ( const Vector2D< TYPE > &  left,
const Vector2D< TYPE > &  right 
)
related

Returns the determinant of the two vectors.

◆ dot()

template<class TYPE >
TYPE dot ( const Vector2D< TYPE > &  left,
const Vector2D< TYPE > &  right 
)
related

Returns the dot product of the two vectors.

◆ operator*() [1/2]

template<class TYPE >
Vector2D< TYPE > operator* ( const TYPE &  left,
const Vector2D< TYPE > &  right 
)
related

Returns the product of the vector and the value.

◆ operator*() [2/2]

template<class TYPE >
Vector2D< TYPE > operator* ( const Vector2D< TYPE > &  left,
const TYPE &  right 
)
related

Returns the product of the vector and the value.

◆ operator+()

template<class TYPE >
Vector2D< TYPE > operator+ ( const Vector2D< TYPE > &  left,
const Vector2D< TYPE > &  right 
)
related

Returns the sum of the vectors.

◆ operator-()

template<class TYPE >
Vector2D< TYPE > operator- ( const Vector2D< TYPE > &  left,
const Vector2D< TYPE > &  right 
)
related

Returns the difference of the vectors.

◆ operator/()

template<class TYPE >
Vector2D< TYPE > operator/ ( const Vector2D< TYPE > &  left,
const TYPE &  right 
)
related

Returns the ratio of the vector and the value.

◆ operator<<()

template<class TYPE >
FormatOutputStream & operator<< ( FormatOutputStream stream,
const Vector2D< TYPE > &  value 
)
related

Writes a string representation of a Vector2D object to a format stream. The format is "(x; y)".

Member Data Documentation

◆ x

template<class TYPE >
TYPE Vector2D< TYPE >::x = 0
protected

The X coordinate.

◆ y

template<class TYPE >
TYPE Vector2D< TYPE >::y = 0
protected

The Y coordinate.