mu
mu::Vector3D< T > Class Template Reference

A three dimensional vector. More...

#include <vector3d.h>

Inheritance diagram for mu::Vector3D< T >:
Collaboration diagram for mu::Vector3D< T >:

Public Member Functions

template<class Tt = T>
 Vector3D (const Vector< 3, T > &other)
 Construct a new Vector3D object from a Vector object. More...
 
T & x () noexcept
 x component More...
 
const T & x () const noexcept
 const x component More...
 
T & y () noexcept
 y component More...
 
const T & y () const noexcept
 const y component More...
 
T & z () noexcept
 z component More...
 
const T & z () const noexcept
 const z component More...
 
- Public Member Functions inherited from mu::Vector< 3, T >
constexpr Vector ()=default
 Construct a new Vector object. More...
 
 Vector (TArgs &&... args)
 Construct a new Vector object from a number of N values. More...
 
 Vector (const Vector< Nn, U > &v)
 Construct a new Vector from an existing Vector of a different type. More...
 
 Vector (const std::array< T, N > &a)
 Construct a new Vector object from an std::array. More...
 
 Vector (const std::array< U, N > &a)
 Construct a new Vector object from an std::array of a different type. More...
 
 Vector (const U &value)
 Construct a new Vector object from a single value. More...
 
 Vector (const Vector &other)=default
 Copy construct a new Vector object. More...
 
 Vector (Vector &&other) noexcept=default
 Move construct a new Vector object. More...
 
 ~Vector ()=default
 Destroy the Vector object.
 
Vector & operator= (const Vector &other)=default
 Copy assignment operator. More...
 
Vector & operator= (Vector &&other) noexcept=default
 Move assignment operator. More...
 
T & operator[] (size_type idx) noexcept
 access an element within the vector More...
 
const T & operator[] (size_type idx) const noexcept
 const access an element within the vector More...
 
T & at (size_type idx)
 access an element within the vector More...
 
const T & at (size_type idx) const
 const access an element within the vector More...
 
constexpr size_type size () const noexcept
 returns the size of the vector More...
 
iterator begin () noexcept
 returns an iterator pointing to the first element More...
 
const_iterator begin () const noexcept
 returns a const iterator pointing to the first element More...
 
iterator end () noexcept
 returns an iterator pointing to the element following the last element More...
 
const_iterator end () const noexcept
 returns a const iterator pointing to the element following the last element More...
 
T min () const
 get the min value of the vector More...
 
T max () const
 get the max value of the vector More...
 
T sum () const
 sum up all the elements of the vector More...
 
U mean () const
 mean of all the elements of the vector More...
 
std::conditional_t< std::is_same< U, void >::value, T, U > dot (const Vector< N2, T2 > &rhs) const
 dot product of two vectors More...
 
std::conditional_t< std::is_same< U, void >::value, Vector< M2, T >, Vector< M2, U > > dot (const Matrix< N2, M2, T2 > &rhs) const
 dot product of a vector and a matrix More...
 
U std () const
 calculates the standard deviation More...
 
U length () const
 euclidean vector length More...
 
void normalize ()
 normalizes this vector More...
 
Vector< N, T > normalized ()
 returns a normalized vector More...
 
void flip ()
 flips this vector, i.e. reverses its elements More...
 
Vector< N, T > flipped () const
 returns a flipped vector More...
 
void sort ()
 sort vector elements in ascending order More...
 
void sort (const Compare &comp)
 sort vector elements by providing a condition More...
 
Vector< N, T > sorted () const
 returns a sorted vector More...
 
Vector< N, T > sorted (const Compare &comp) const
 
bool operator== (const Vector< N, U > &rhs) const
 equality operator More...
 
bool operator!= (const Vector< N, U > &rhs) const
 unequality operator More...
 
Vector< N, T > & operator+= (const Vector< N, U > &rhs)
 plus equal operator More...
 
std::enable_if_t< std::is_arithmetic< TScalar >::value, Vector< N, T > &> operator+= (const TScalar &scalar)
 add a scalar to this vector More...
 
Vector< N, T > & operator-= (const Vector< N, U > &rhs)
 minus equal operator More...
 
std::enable_if_t< std::is_arithmetic< TScalar >::value, Vector< N, T > &> operator-= (const TScalar &scalar)
 subtract a scalar from every element of this vector More...
 
Vector< N, T > & operator*= (const Vector< N, U > &rhs)
 multiplication equal operator More...
 
std::enable_if_t< std::is_arithmetic< TScalar >::value, Vector< N, T > &> operator*= (const TScalar &scalar)
 multiply a scalar with this vector More...
 
Vector< N, T > & operator/= (const Vector< N, U > &rhs)
 divison equal operator More...
 
std::enable_if_t< std::is_arithmetic< TScalar >::value, Vector< N, T > &> operator/= (const TScalar &scalar)
 divide every element of this vector by a scalar More...
 

Additional Inherited Members

- Public Types inherited from mu::Vector< 3, T >
using value_type = typename std::array< T, N >::value_type
 
using size_type = typename std::array< T, N >::size_type
 
using iterator = typename std::array< T, N >::iterator
 
using const_iterator = typename std::array< T, N >::const_iterator
 
- Protected Attributes inherited from mu::Vector< 3, T >
std::array< T, N > data_
 

Detailed Description

template<typename T>
class mu::Vector3D< T >

A three dimensional vector.

Template Parameters
Ttype

Constructor & Destructor Documentation

◆ Vector3D()

template<typename T >
template<class Tt = T>
mu::Vector3D< T >::Vector3D ( const Vector< 3, T > &  other)
inline

Construct a new Vector3D object from a Vector object.

Example
mu::Vector3D<float> a = {1.5F, 2.5F, 3.5F};
Parameters
idx
Template Parameters
Tt
Parameters
other

Member Function Documentation

◆ x() [1/2]

template<typename T>
T& mu::Vector3D< T >::x ( )
inlinenoexcept

x component

Example
mu::Vector3D<int> a = {7, 8, 9};
int x = a.x();
Returns
T&

◆ x() [2/2]

template<typename T>
const T& mu::Vector3D< T >::x ( ) const
inlinenoexcept

const x component

Example
const mu::Vector3D<int> a = {7, 8, 9};
int x = a.x();
Returns
const T&

◆ y() [1/2]

template<typename T>
T& mu::Vector3D< T >::y ( )
inlinenoexcept

y component

Example
mu::Vector3D<int> a = {7, 8, 9};
int y = a.y();
Returns
T&

◆ y() [2/2]

template<typename T>
const T& mu::Vector3D< T >::y ( ) const
inlinenoexcept

const y component

Example
const mu::Vector3D<int> a = {7, 8, 9};
int y = a.y();
Returns
const T&

◆ z() [1/2]

template<typename T>
T& mu::Vector3D< T >::z ( )
inlinenoexcept

z component

Example
mu::Vector3D<int> a = {7, 8, 9};
int z = a.z();
Returns
T&

◆ z() [2/2]

template<typename T>
const T& mu::Vector3D< T >::z ( ) const
inlinenoexcept

const z component

Example
const mu::Vector3D<int> a = {7, 8, 9};
int z = a.z();
Returns
const T&

The documentation for this class was generated from the following file: