RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
RST::Maths::Vector3D< T > Struct Template Reference

3D vector; arithmetic operators work component-wise, with a vector or a scalar. More...

#include <RST/maths/Vector.hpp>

Public Member Functions

constexpr Vector3D () noexcept=default
 
constexpr Vector3D (T xValue, T yValue, T zValue) noexcept
 
constexpr void set (const T &newX, const T &newY, const T &newZ) noexcept
 
constexpr T getX () const noexcept
 
constexpr T getY () const noexcept
 
constexpr T getZ () const noexcept
 
constexpr T & operator[] (std::size_t n) noexcept
 
constexpr const T & operator[] (std::size_t n) const noexcept
 
constexpr T * data () noexcept
 
constexpr const T * data () const noexcept
 
constexpr Vector3D operator+ () const noexcept
 
constexpr Vector3D operator- () const noexcept
 
constexpr Vector3D & operator+= (const Vector3D &v) noexcept
 
constexpr Vector3D & operator-= (const Vector3D &v) noexcept
 
constexpr Vector3D & operator*= (const Vector3D &v) noexcept
 
constexpr Vector3D & operator/= (const Vector3D &v) noexcept
 
constexpr Vector3D & operator*= (T s) noexcept
 
constexpr Vector3D & operator/= (T s) noexcept
 
constexpr Vector3D & operator+= (T s) noexcept
 
constexpr Vector3D & operator-= (T s) noexcept
 
constexpr bool operator== (const Vector3D &) const noexcept=default
 
constexpr T dot (const Vector3D &v) const noexcept
 
constexpr Vector3D cross (const Vector3D &v) const noexcept
 
constexpr auto lengthSquared () const noexcept
 
constexpr auto length () const noexcept
 
constexpr auto distanceSquared (const Vector3D &v) const noexcept
 
constexpr auto distance (const Vector3D &v) const noexcept
 
constexpr Vector3D & normalize () noexcept
 Scales this vector to length 1; a zero vector is left unchanged.
 
constexpr Vector3D normalized () const noexcept
 
template<typename U >
constexpr Vector3D< U > to () const noexcept
 Converts the components, such as v.to<int>().
 
constexpr Vector3D min (const Vector3D &v) const noexcept
 Component-wise minimum.
 
constexpr Vector3D max (const Vector3D &v) const noexcept
 Component-wise maximum.
 

Public Attributes

T x {}
 
T y {}
 
T z {}
 

Detailed Description

template<typename T>
struct RST::Maths::Vector3D< T >

3D vector; arithmetic operators work component-wise, with a vector or a scalar.

Examples
graphics.cpp.

Constructor & Destructor Documentation

◆ Vector3D() [1/2]

template<typename T >
constexpr RST::Maths::Vector3D< T >::Vector3D ( )
constexprdefaultnoexcept

◆ Vector3D() [2/2]

template<typename T >
constexpr RST::Maths::Vector3D< T >::Vector3D ( T  xValue,
T  yValue,
T  zValue 
)
inlineconstexprnoexcept

Member Function Documentation

◆ set()

template<typename T >
constexpr void RST::Maths::Vector3D< T >::set ( const T &  newX,
const T &  newY,
const T &  newZ 
)
inlineconstexprnoexcept

◆ getX()

template<typename T >
constexpr T RST::Maths::Vector3D< T >::getX ( ) const
inlineconstexprnoexcept

◆ getY()

template<typename T >
constexpr T RST::Maths::Vector3D< T >::getY ( ) const
inlineconstexprnoexcept

◆ getZ()

template<typename T >
constexpr T RST::Maths::Vector3D< T >::getZ ( ) const
inlineconstexprnoexcept

◆ operator[]() [1/2]

template<typename T >
constexpr T & RST::Maths::Vector3D< T >::operator[] ( std::size_t  n)
inlineconstexprnoexcept

◆ operator[]() [2/2]

template<typename T >
constexpr const T & RST::Maths::Vector3D< T >::operator[] ( std::size_t  n) const
inlineconstexprnoexcept

◆ data() [1/2]

template<typename T >
constexpr T * RST::Maths::Vector3D< T >::data ( )
inlineconstexprnoexcept

◆ data() [2/2]

template<typename T >
constexpr const T * RST::Maths::Vector3D< T >::data ( ) const
inlineconstexprnoexcept

◆ operator+()

template<typename T >
constexpr Vector3D RST::Maths::Vector3D< T >::operator+ ( ) const
inlineconstexprnoexcept

◆ operator-()

template<typename T >
constexpr Vector3D RST::Maths::Vector3D< T >::operator- ( ) const
inlineconstexprnoexcept

◆ operator+=() [1/2]

template<typename T >
constexpr Vector3D & RST::Maths::Vector3D< T >::operator+= ( const Vector3D< T > &  v)
inlineconstexprnoexcept

◆ operator-=() [1/2]

template<typename T >
constexpr Vector3D & RST::Maths::Vector3D< T >::operator-= ( const Vector3D< T > &  v)
inlineconstexprnoexcept

◆ operator*=() [1/2]

template<typename T >
constexpr Vector3D & RST::Maths::Vector3D< T >::operator*= ( const Vector3D< T > &  v)
inlineconstexprnoexcept

◆ operator/=() [1/2]

template<typename T >
constexpr Vector3D & RST::Maths::Vector3D< T >::operator/= ( const Vector3D< T > &  v)
inlineconstexprnoexcept

◆ operator*=() [2/2]

template<typename T >
constexpr Vector3D & RST::Maths::Vector3D< T >::operator*= ( T  s)
inlineconstexprnoexcept

◆ operator/=() [2/2]

template<typename T >
constexpr Vector3D & RST::Maths::Vector3D< T >::operator/= ( T  s)
inlineconstexprnoexcept

◆ operator+=() [2/2]

template<typename T >
constexpr Vector3D & RST::Maths::Vector3D< T >::operator+= ( T  s)
inlineconstexprnoexcept

◆ operator-=() [2/2]

template<typename T >
constexpr Vector3D & RST::Maths::Vector3D< T >::operator-= ( T  s)
inlineconstexprnoexcept

◆ operator==()

template<typename T >
constexpr bool RST::Maths::Vector3D< T >::operator== ( const Vector3D< T > &  ) const
constexprdefaultnoexcept

◆ dot()

template<typename T >
constexpr T RST::Maths::Vector3D< T >::dot ( const Vector3D< T > &  v) const
inlineconstexprnoexcept

◆ cross()

template<typename T >
constexpr Vector3D RST::Maths::Vector3D< T >::cross ( const Vector3D< T > &  v) const
inlineconstexprnoexcept

◆ lengthSquared()

template<typename T >
constexpr auto RST::Maths::Vector3D< T >::lengthSquared ( ) const
inlineconstexprnoexcept

◆ length()

template<typename T >
constexpr auto RST::Maths::Vector3D< T >::length ( ) const
inlineconstexprnoexcept

◆ distanceSquared()

template<typename T >
constexpr auto RST::Maths::Vector3D< T >::distanceSquared ( const Vector3D< T > &  v) const
inlineconstexprnoexcept

◆ distance()

template<typename T >
constexpr auto RST::Maths::Vector3D< T >::distance ( const Vector3D< T > &  v) const
inlineconstexprnoexcept

◆ normalize()

template<typename T >
constexpr Vector3D & RST::Maths::Vector3D< T >::normalize ( )
inlineconstexprnoexcept

Scales this vector to length 1; a zero vector is left unchanged.

◆ normalized()

template<typename T >
constexpr Vector3D RST::Maths::Vector3D< T >::normalized ( ) const
inlineconstexprnoexcept

◆ to()

template<typename T >
template<typename U >
constexpr Vector3D< U > RST::Maths::Vector3D< T >::to ( ) const
inlineconstexprnoexcept

Converts the components, such as v.to<int>().

◆ min()

template<typename T >
constexpr Vector3D RST::Maths::Vector3D< T >::min ( const Vector3D< T > &  v) const
inlineconstexprnoexcept

Component-wise minimum.

◆ max()

template<typename T >
constexpr Vector3D RST::Maths::Vector3D< T >::max ( const Vector3D< T > &  v) const
inlineconstexprnoexcept

Component-wise maximum.

Member Data Documentation

◆ x

template<typename T >
T RST::Maths::Vector3D< T >::x {}

◆ y

template<typename T >
T RST::Maths::Vector3D< T >::y {}

◆ z

template<typename T >
T RST::Maths::Vector3D< T >::z {}

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