CodeSubWars 0.4.7b
ARSTD::Vector3< Type > Struct Template Reference

#include <Vector3.h>

Public Member Functions

 Vector3 (const Type &x=0, const Type &y=0, const Type &z=0)
 
const Type getLength () const
 
const Type getSquaredLength () const
 
const Vector3< Type > & normalize ()
 
Vector3< Type > getNormalized () const
 
Vector3< Type > getRotated (const Vector3< Type > &vecAxis, const Type &angle) const
 
double getDistance (const Vector3< Type > &vec) const
 
Type getAngleBetween (const Vector3< Type > &vec) const
 
Vector3< Type > getPerpendicular () const
 

Static Public Member Functions

static Vector3< Type > lerp (const Vector3< Type > &vec1, const Vector3< Type > &vec2, const double &t)
 

Related Functions

(Note that these are not member functions.)

template<class Type >
Vector3< Type > operator- (const Vector3< Type > &vec)
 
template<class Type >
const Type operator* (const Vector3< Type > &lhs, const Vector3< Type > &rhs)
 
template<class Type >
Vector3< Type > operator% (const Vector3< Type > &lhs, const Vector3< Type > &rhs)
 
template<class Type >
Vector3< Type > operator+ (const Vector3< Type > &lhs, const Vector3< Type > &rhs)
 
template<class Type >
Vector3< Type > operator* (const Vector3< Type > &lhs, const Type &rhs)
 
template<class Type >
Vector3< Type > operator* (const Type &lhs, const Vector3< Type > &rhs)
 
template<class Type >
Vector3< Type > operator/ (const Vector3< Type > &lhs, const Type &rhs)
 
template<class Type >
bool equals (const Vector3< Type > &lhs, const Vector3< Type > &rhs, double fEpsilon=EPSILON)
 
template<class Type >
bool operator== (const Vector3< Type > &lhs, const Vector3< Type > &rhs)
 
template<class Type >
bool operator!= (const Vector3< Type > &lhs, const Vector3< Type > &rhs)
 
template<class Type >
std::ostream & operator<< (std::ostream &stream, const Vector3< Type > &vec)
 
template<class Type >
std::istream & operator>> (std::istream &stream, Vector3< Type > &vec)
 
template<class Type >
Type distance (const Vector3< Type > &vec1, const Vector3< Type > &vec2)
 
template<typename Type >
Vector3< Type > minimum (const Vector3< Type > &lhs, const Vector3< Type > &rhs)
 
template<typename Type >
Vector3< Type > maximum (const Vector3< Type > &lhs, const Vector3< Type > &rhs)
 

Detailed Description

template<class Type>
struct ARSTD::Vector3< Type >

This represents a 3-dimensional vector

Constructor & Destructor Documentation

◆ Vector3()

template<class Type >
ARSTD::Vector3< Type >::Vector3 ( const Type &  x = 0,
const Type &  y = 0,
const Type &  z = 0 
)

Constructs a vector from given components

Parameters
xx-component
yy-component
zz-component

Member Function Documentation

◆ getAngleBetween()

template<class Type >
Type ARSTD::Vector3< Type >::getAngleBetween ( const Vector3< Type > &  vec) const

Returns the angle the given vector

◆ getDistance()

template<class Type >
double ARSTD::Vector3< Type >::getDistance ( const Vector3< Type > &  vec) const

Returns the distance to given vector

◆ getLength()

template<class Type >
const Type ARSTD::Vector3< Type >::getLength ( ) const

Returns the length

Returns
length of the vector

◆ getNormalized()

template<class Type >
Vector3< Type > ARSTD::Vector3< Type >::getNormalized ( ) const

Returns the normalized version of this vector

Precondition
getLength() != 0.0
Returns
The normalized vector

◆ getPerpendicular()

template<class Type >
Vector3< Type > ARSTD::Vector3< Type >::getPerpendicular ( ) const

Returns a some perpendicular vector

Returns
The perpendicular vector
Precondition
The length must be not zero

◆ getRotated()

template<class Type >
Vector3< Type > ARSTD::Vector3< Type >::getRotated ( const Vector3< Type > &  vecAxis,
const Type &  angle 
) const

Rotates the vector around given axis and angle

Parameters
vecAxisthe axis the vector is rotated around
anglethe angle the vector is rotated around in rad

◆ getSquaredLength()

template<class Type >
const Type ARSTD::Vector3< Type >::getSquaredLength ( ) const

Returns the squared length

Returns
Squared length of the vector.

◆ lerp()

template<class Type >
static Vector3< Type > ARSTD::Vector3< Type >::lerp ( const Vector3< Type > &  vec1,
const Vector3< Type > &  vec2,
const double &  t 
)
static

Linear interpolation of two vectors

Returns
The interpolated vector

◆ normalize()

template<class Type >
const Vector3< Type > & ARSTD::Vector3< Type >::normalize ( )

Normalizes the vector to a length of 1

Precondition
getLength() != 0.0
Postcondition
getLength() is 1
Returns
The normalized vector

Friends And Related Function Documentation

◆ distance()

template<class Type >
Type distance ( const Vector3< Type > &  vec1,
const Vector3< Type > &  vec2 
)
related

Calculates the distance between to vectors

◆ equals()

template<class Type >
bool equals ( const Vector3< Type > &  lhs,
const Vector3< Type > &  rhs,
double  fEpsilon = EPSILON 
)
related

Compares two vectors with the epsilon given by the parameter fEpsilon

Returns
true, if the vectors are considered equal, false otherwise

◆ maximum()

template<typename Type >
Vector3< Type > maximum ( const Vector3< Type > &  lhs,
const Vector3< Type > &  rhs 
)
related

Calculates the component wise maximal vector from the given ones

◆ minimum()

template<typename Type >
Vector3< Type > minimum ( const Vector3< Type > &  lhs,
const Vector3< Type > &  rhs 
)
related

Calculates the component wise minimal vector from the given ones

◆ operator!=()

template<class Type >
bool operator!= ( const Vector3< Type > &  lhs,
const Vector3< Type > &  rhs 
)
related

Compares two matrices using default EPSILON

Returns
true, if the vectors are considered as not equal, false otherwise

◆ operator%()

template<class Type >
Vector3< Type > operator% ( const Vector3< Type > &  lhs,
const Vector3< Type > &  rhs 
)
related

Calculates the cross product

Returns
The cross product

◆ operator*() [1/3]

template<class Type >
Vector3< Type > operator* ( const Type &  lhs,
const Vector3< Type > &  rhs 
)
related

Multiplies a scalar by each component of a vector

Returns
The result of the operation

◆ operator*() [2/3]

template<class Type >
Vector3< Type > operator* ( const Vector3< Type > &  lhs,
const Type &  rhs 
)
related

Multiplies a scalar by each component of a vector

Returns
The result of the operation

◆ operator*() [3/3]

template<class Type >
const Type operator* ( const Vector3< Type > &  lhs,
const Vector3< Type > &  rhs 
)
related

Calculates the dot product

Returns
The dot product

◆ operator+()

template<class Type >
Vector3< Type > operator+ ( const Vector3< Type > &  lhs,
const Vector3< Type > &  rhs 
)
related

Calculates the addition

Returns
The added vector

◆ operator-()

template<class Type >
Vector3< Type > operator- ( const Vector3< Type > &  vec)
related

Negates all components

Returns
The negated vector

◆ operator/()

template<class Type >
Vector3< Type > operator/ ( const Vector3< Type > &  lhs,
const Type &  rhs 
)
related

Divides each component of a vector by a scalar

Returns
The result of the operation

◆ operator<<()

template<class Type >
std::ostream & operator<< ( std::ostream &  stream,
const Vector3< Type > &  vec 
)
related

Writes the vector to a std output stream

◆ operator==()

template<class Type >
bool operator== ( const Vector3< Type > &  lhs,
const Vector3< Type > &  rhs 
)
related

Compares two matrices using default EPSILON

Returns
true, if the vectors are considered equal, false otherwise

◆ operator>>()

template<class Type >
std::istream & operator>> ( std::istream &  stream,
Vector3< Type > &  vec 
)
related

Reads the vector from a std input stream


Generated at Sun Aug 7 2022 for project CodeSubWars. www.codesubwars.org