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

Three-dimensional vector. More...

#include <base/math/Vector3D.h>

Public Member Functions

 Vector3D () noexcept
 
 Vector3D (const TYPE &x, const TYPE &y, const TYPE &z) noexcept
 
 Vector3D (const Vector3D &copy) noexcept
 
Vector3Doperator= (const Vector3D &assign) noexcept
 
TYPE getSqrModulus () const noexcept
 
TYPE getModulus () const noexcept
 
TYPE getXYAngle () const noexcept
 
TYPE getZAngle () const noexcept
 
TYPE getX () const noexcept
 
TYPE getY () const noexcept
 
TYPE getZ () const noexcept
 
void setX (const TYPE &x) noexcept
 
void setY (const TYPE &y) noexcept
 
void setZ (const TYPE &z) noexcept
 
Vector3DzeroAdjust (const TYPE &zero) noexcept
 
bool isZero () const noexcept
 
bool isProper () const noexcept
 
bool isOrthogonal (const Vector3D &value) const noexcept
 
bool isParallel (const Vector3D &value) const noexcept
 
Vector3D plus () const noexcept
 
Vector3D minus () const noexcept
 
Vector3Dnegate () noexcept
 
Vector3Dadd (const Vector3D &value) noexcept
 
Vector3Dsubtract (const Vector3D &value) noexcept
 
Vector3Dmultiply (const TYPE &value) noexcept
 
Vector3Ddivide (const TYPE &value) noexcept
 
TYPE dot (const Vector3D &value) const noexcept
 
Vector3D cross (const Vector3D &value) const noexcept
 
TYPE getAngle (const Vector3D &value) const noexcept
 
Vector3D getProjection (const Vector3D &value) const noexcept
 
bool operator== (const Vector3D &value) const noexcept
 
Vector3Doperator+= (const Vector3D &value) noexcept
 
Vector3Doperator-= (const Vector3D &value) noexcept
 
Vector3Doperator*= (const TYPE &value) noexcept
 
Vector3Doperator/= (const TYPE &value) noexcept
 
Vector3D operator+ () const noexcept
 
Vector3D operator- () const noexcept
 

Protected Attributes

TYPE x = 0
 
TYPE y = 0
 
TYPE z = 0
 

Related Functions

(Note that these are not member functions.)

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

Detailed Description

template<class TYPE>
class Vector3D< TYPE >

Three-dimensional vector.

A three-dimensional vector represented by X, Y, and Z coordinates.

Version
1.1

Constructor & Destructor Documentation

◆ Vector3D() [1/3]

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

Initializes vector as origin (0, 0, 0).

◆ Vector3D() [2/3]

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

Initializes vector from the specified coordinates.

Parameters
xThe desired X coordinate.
yThe desired Y coordinate.
zThe desired Z coordinate.

◆ Vector3D() [3/3]

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

Initializes vector by copying from the specified vector.

Parameters
vectorThe desired vector.

Member Function Documentation

◆ add()

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

Adds the specified vector to this vector.

◆ cross()

template<class TYPE >
Vector3D Vector3D< TYPE >::cross ( const Vector3D< TYPE > &  value) const
inlinenoexcept

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

◆ divide()

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

Divides this vector with the specified value.

◆ dot()

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

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

◆ getAngle()

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

Returns the angle between this vector and the specified vector.

◆ getModulus()

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

Returns the modulus of the vector.

◆ getProjection()

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

Returns the projection of this vector onto the specified vector.

◆ getSqrModulus()

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

Returns the square of the modulus of the vector.

◆ getX()

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

Returns the X coordinate of the vector.

◆ getXYAngle()

template<class TYPE >
TYPE Vector3D< TYPE >::getXYAngle ( ) const
inlinenoexcept

Returns the angle of this vector in the X-Y plane.

◆ getY()

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

Returns the Y coordinate of the vector.

◆ getZ()

template<class TYPE >
TYPE Vector3D< TYPE >::getZ ( ) const
inlinenoexcept

Returns the Z coordinate of the vector.

◆ getZAngle()

template<class TYPE >
TYPE Vector3D< TYPE >::getZAngle ( ) const
inlinenoexcept

Returns the angle between this vector and the X-Y plane.

◆ isOrthogonal()

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

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

◆ isParallel()

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

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

◆ isProper()

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

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

◆ isZero()

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

Returns true if the length of this vector is zero.

◆ minus()

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

Unary minus.

◆ multiply()

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

Multiplies this vector with the specified value.

◆ negate()

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

Negates this vector.

◆ operator*=()

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

Multiplies this vector with the specified value.

Parameters
valueThe multiplicator.

◆ operator+()

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

Unary plus.

◆ operator+=()

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

Adds the specified vector from this vector.

Parameters
valueThe value to be added.

◆ operator-()

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

Unary minus.

◆ operator-=()

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

Subtracts the specified vector from this vector.

Parameters
valueThe value to be subtracted.

◆ operator/=()

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

Divides this vector with the specified value.

Parameters
valueThe divisor.

◆ operator=()

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

Assignment of this vector from vector.

◆ operator==()

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

Returns true if the vectors are equal.

Parameters
vectorVector to be compared.

◆ plus()

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

Unary plus.

◆ setX()

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

Sets the X coordinate of the vector.

Parameters
xThe desired X coordinate.

◆ setY()

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

Sets the Y coordinate of the vector.

Parameters
yThe desired Y coordinate.

◆ setZ()

template<class TYPE >
void Vector3D< TYPE >::setZ ( const TYPE &  z)
inlinenoexcept

Sets the Z coordinate of the vector.

Parameters
zThe desired Z coordinate.

◆ subtract()

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

Subtracts the specified vector from this vector.

◆ zeroAdjust()

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

Sets values less than the specified value to zero.

Friends And Related Function Documentation

◆ cross()

template<class TYPE >
Vector3D< TYPE > cross ( const Vector3D< TYPE > &  left,
const Vector3D< TYPE > &  right 
)
related

Returns the cross product of the two vectors.

◆ dot()

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

Returns the dot product of the two vectors.

◆ operator*() [1/2]

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

Returns the product of the vector and the value.

◆ operator*() [2/2]

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

Returns the product of the vector and the value.

◆ operator+()

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

Returns the sum of the vectors.

◆ operator-()

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

Returns the difference of the vectors.

◆ operator/()

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

Returns the result of the vector divided by the value.

◆ operator<<()

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

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

Member Data Documentation

◆ x

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

X coordinate.

◆ y

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

Y coordinate.

◆ z

template<class TYPE >
TYPE Vector3D< TYPE >::z = 0
protected

Z coordinate.