Tuesday
Classes | Typedefs | Functions
<tue/vec.hpp>

Detailed Description

The vec class template and its associated utility structs and functions.

Classes

struct  tue::is_vec_component< T >
 Checks if a type can be used as the component type of a vec. More...
 
class  tue::vec< T, N >
 An N-dimensional vector. More...
 

Typedefs

template<typename T >
using tue::vec2 = vec< T, 2 >
 A 2-dimensional vector. More...
 
template<typename T >
using tue::vec3 = vec< T, 3 >
 A 3-dimensional vector. More...
 
template<typename T >
using tue::vec4 = vec< T, 4 >
 A 4-dimensional vector. More...
 
using tue::fvec2 = vec2< float >
 A 2-dimensional vector with float components. More...
 
using tue::fvec3 = vec3< float >
 A 3-dimensional vector with float components. More...
 
using tue::fvec4 = vec4< float >
 A 4-dimensional vector with float components. More...
 
using tue::dvec2 = vec2< double >
 A 2-dimensional vector with double components. More...
 
using tue::dvec3 = vec3< double >
 A 3-dimensional vector with double components. More...
 
using tue::dvec4 = vec4< double >
 A 4-dimensional vector with double components. More...
 
using tue::ivec2 = vec2< int >
 A 2-dimensional vector with int components. More...
 
using tue::ivec3 = vec3< int >
 A 3-dimensional vector with int components. More...
 
using tue::ivec4 = vec4< int >
 A 4-dimensional vector with int components. More...
 
using tue::uvec2 = vec2< unsigned int >
 A 2-dimensional vector with unsigned int components. More...
 
using tue::uvec3 = vec3< unsigned int >
 A 3-dimensional vector with unsigned int components. More...
 
using tue::uvec4 = vec4< unsigned int >
 A 4-dimensional vector with unsigned int components. More...
 

Functions

template<typename T , int N>
constexpr vec< decltype(+std::declval< T >)), N > tue::operator+ (const vec< T, N > &v) noexcept
 Computes the unary plus of each component of v. More...
 
template<typename T , int N>
constexpr vec< decltype(-std::declval< T >)), N > tue::operator- (const vec< T, N > &v) noexcept
 Computes the unary minus of each component of v. More...
 
template<typename T , int N>
constexpr vec< decltype(~std::declval< T >)), N > tue::operator~ (const vec< T, N > &v) noexcept
 Computes the bitwise NOT of each component of v. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< T >::value, vec< decltype(std::declval< T >)+std::declval< U >)), N > > tue::operator+ (const T &lhs, const vec< U, N > &rhs) noexcept
 Computes the sums of lhs and each component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< U >::value, vec< decltype(std::declval< T >)+std::declval< U >)), N > > tue::operator+ (const vec< T, N > &lhs, const U &rhs) noexcept
 Computes the sums of each component of lhs and rhs. More...
 
template<typename T , typename U , int N>
constexpr vec< decltype(std::declval< T >)+std::declval< U >)), N > tue::operator+ (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Computes the sums of each component of lhs and each corresponding component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< T >::value, vec< decltype(std::declval< T >)-std::declval< U >)), N > > tue::operator- (const T &lhs, const vec< U, N > &rhs) noexcept
 Computes the differences between lhs and each component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< U >::value, vec< decltype(std::declval< T >)-std::declval< U >)), N > > tue::operator- (const vec< T, N > &lhs, const U &rhs) noexcept
 Computes the differences between each component of lhs and rhs. More...
 
template<typename T , typename U , int N>
constexpr vec< decltype(std::declval< T >)-std::declval< U >)), N > tue::operator- (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Computes the differences between each component of lhs and each corresponding component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< T >::value, vec< decltype(std::declval< T >)*std::declval< U >)), N > > tue::operator* (const T &lhs, const vec< U, N > &rhs) noexcept
 Computes the products of lhs and each component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< U >::value, vec< decltype(std::declval< T >)*std::declval< U >)), N > > tue::operator* (const vec< T, N > &lhs, const U &rhs) noexcept
 Computes the products of each component of lhs and rhs. More...
 
template<typename T , typename U , int N>
constexpr vec< decltype(std::declval< T >)*std::declval< U >)), N > tue::operator* (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Computes the products of each component of lhs and each corresponding component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< T >::value, vec< decltype(std::declval< T >)/std::declval< U >)), N > > tue::operator/ (const T &lhs, const vec< U, N > &rhs) noexcept
 Computes the quotients of lhs over each component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< U >::value, vec< decltype(std::declval< T >)/std::declval< U >)), N > > tue::operator/ (const vec< T, N > &lhs, const U &rhs) noexcept
 Computes the quotients of each component of lhs over rhs. More...
 
template<typename T , typename U , int N>
constexpr vec< decltype(std::declval< T >)/std::declval< U >)), N > tue::operator/ (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Computes the quotients of each component of lhs over each corresponding component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< T >::value, vec< decltype(std::declval< T >)%std::declval< U >)), N > > tue::operator% (const T &lhs, const vec< U, N > &rhs) noexcept
 Computes the modulos of lhs over each component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< U >::value, vec< decltype(std::declval< T >)%std::declval< U >)), N > > tue::operator% (const vec< T, N > &lhs, const U &rhs) noexcept
 Computes the modulos of each component of lhs over rhs. More...
 
template<typename T , typename U , int N>
constexpr vec< decltype(std::declval< T >)%std::declval< U >)), N > tue::operator% (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Computes the modulos of each component of lhs over each corresponding component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< T >::value, vec< decltype(std::declval< T >)&std::declval< U >)), N > > tue::operator& (const T &lhs, const vec< U, N > &rhs) noexcept
 Computes the bitwise AND of lhs and each component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< U >::value, vec< decltype(std::declval< T >)&std::declval< U >)), N > > tue::operator& (const vec< T, N > &lhs, const U &rhs) noexcept
 Computes the bitwise AND of each component of lhs and rhs. More...
 
template<typename T , typename U , int N>
constexpr vec< decltype(std::declval< T >)&std::declval< U >)), N > tue::operator& (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Computes the bitwise AND of each component of lhs and each corresponding component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< T >::value, vec< decltype(std::declval< T >)|std::declval< U >)), N > > tue::operator| (const T &lhs, const vec< U, N > &rhs) noexcept
 Computes the bitwise OR of lhs and each component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< U >::value, vec< decltype(std::declval< T >)|std::declval< U >)), N > > tue::operator| (const vec< T, N > &lhs, const U &rhs) noexcept
 Computes the bitwise OR of each component of lhs and rhs. More...
 
template<typename T , typename U , int N>
constexpr vec< decltype(std::declval< T >)|std::declval< U >)), N > tue::operator| (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Computes the bitwise OR of each component of lhs and each corresponding component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< T >::value, vec< decltype(std::declval< T >)^std::declval< U >)), N > > tue::operator^ (const T &lhs, const vec< U, N > &rhs) noexcept
 Computes the bitwise XOR of lhs and each component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< U >::value, vec< decltype(std::declval< T >)^std::declval< U >)), N > > tue::operator^ (const vec< T, N > &lhs, const U &rhs) noexcept
 Computes the bitwise XOR of each component of lhs and rhs. More...
 
template<typename T , typename U , int N>
constexpr vec< decltype(std::declval< T >)^std::declval< U >)), N > tue::operator^ (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Computes the bitwise XOR of each component of lhs and each corresponding component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< T >::value, vec< decltype(std::declval< T >) shift_left std::declval< U >)), N > > tue::operator<< (const T &lhs, const vec< U, N > &rhs) noexcept
 Computes the bitwise shifts left of lhs by each component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< U >::value, vec< decltype(std::declval< T >) shift_left std::declval< U >)), N > > tue::operator<< (const vec< T, N > &lhs, const U &rhs) noexcept
 Computes the bitwise shifts left of each component of lhs by rhs. More...
 
template<typename T , typename U , int N>
constexpr vec< decltype(std::declval< T >) shift_left std::declval< U >)), N > tue::operator<< (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Computes the bitwise shifts left of each component of lhs by each corresponding component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< T >::value, vec< decltype(std::declval< T >) shift_right std::declval< U >)), N > > tue::operator>> (const T &lhs, const vec< U, N > &rhs) noexcept
 Computes the bitwise shifts right of lhs by each component of rhs. More...
 
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component< U >::value, vec< decltype(std::declval< T >) shift_right std::declval< U >)), N > > tue::operator>> (const vec< T, N > &lhs, const U &rhs) noexcept
 Computes the bitwise shifts right of each component of lhs by rhs. More...
 
template<typename T , typename U , int N>
constexpr vec< decltype(std::declval< T >) shift_right std::declval< U >)), N > tue::operator>> (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Computes the bitwise shifts right of each component of lhs by each corresponding component of rhs. More...
 
template<typename T , typename U , int N>
constexpr bool tue::operator== (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Determines whether or not two vec's compare equal. More...
 
template<typename T , typename U , int N>
constexpr bool tue::operator!= (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Determines whether or not two vec's compare not equal. More...
 
template<typename T , int N>
vec< T, N > tue::math::sin (const vec< T, N > &v) noexcept
 Computes tue::math::sin() for each component of v. More...
 
template<typename T , int N>
vec< T, N > tue::math::cos (const vec< T, N > &v) noexcept
 Computes tue::math::cos() for each component of v. More...
 
template<typename T , int N>
void tue::math::sincos (const vec< T, N > &v, vec< T, N > &sin_out, vec< T, N > &cos_out) noexcept
 Computes tue::math::sincos() for each component of v. More...
 
template<typename T , int N>
vec< T, N > tue::math::exp (const vec< T, N > &v) noexcept
 Computes tue::math::exp() for each component of v. More...
 
template<typename T , int N>
vec< T, N > tue::math::log (const vec< T, N > &v) noexcept
 Computes tue::math::log() for each component of v. More...
 
template<typename T , int N>
vec< T, N > tue::math::abs (const vec< T, N > &v) noexcept
 Computes tue::math::abs() for each component of v. More...
 
template<typename T , int N>
vec< T, N > tue::math::pow (const vec< T, N > &bases, const vec< T, N > &exponents) noexcept
 Computes tue::math::pow() for each component of bases and each corresponding component of exponents. More...
 
template<typename T , int N>
vec< T, N > tue::math::recip (const vec< T, N > &v) noexcept
 Computes tue::math::recip() for each component of v. More...
 
template<typename T , int N>
vec< T, N > tue::math::sqrt (const vec< T, N > &v) noexcept
 Computes tue::math::sqrt() for each component of v. More...
 
template<typename T , int N>
vec< T, N > tue::math::rsqrt (const vec< T, N > &v) noexcept
 Computes tue::math::rsqrt() for each component of v. More...
 
template<typename T , int N>
vec< T, N > tue::math::min (const vec< T, N > &v1, const vec< T, N > &v2) noexcept
 Computes tue::math::min() for each corresponding pair of components from v1 and v2. More...
 
template<typename T , int N>
vec< T, N > tue::math::max (const vec< T, N > &v1, const vec< T, N > &v2) noexcept
 Computes tue::math::max() for each corresponding pair of components from v1 and v2. More...
 
template<typename T , typename U , int N>
vec< U, N > tue::math::mask (const vec< T, N > &conditions, const vec< U, N > &values) noexcept
 Computes tue::math::mask() for each corresponding pair of components from conditions and values. More...
 
template<typename T , typename U , int N>
vec< U, N > tue::math::select (const vec< T, N > &conditions, const vec< U, N > &values, const vec< U, N > &otherwise) noexcept
 Computes tue::math::select() for each corresponding trio of components from conditions, values, and otherwise. More...
 
template<typename T , int N>
vec< decltype(tue::math::less(std::declval< T >), std::declval< T >))), N > tue::math::less (const vec< T, N > &lhs, const vec< T, N > &rhs) noexcept
 Computes tue::math::less() for each corresponding pair of components from lhs and rhs. More...
 
template<typename T , int N>
vec< decltype(tue::math::less_equal(std::declval< T >), std::declval< T >))), N > tue::math::less_equal (const vec< T, N > &lhs, const vec< T, N > &rhs) noexcept
 Computes tue::math::less_equal() for each corresponding pair of components from lhs and rhs. More...
 
template<typename T , int N>
vec< decltype(tue::math::greater(std::declval< T >), std::declval< T >))), N > tue::math::greater (const vec< T, N > &lhs, const vec< T, N > &rhs) noexcept
 Computes tue::math::greater() for each corresponding pair of components from lhs and rhs. More...
 
template<typename T , int N>
vec< decltype(tue::math::greater_equal(std::declval< T >), std::declval< T >))), N > tue::math::greater_equal (const vec< T, N > &lhs, const vec< T, N > &rhs) noexcept
 Computes tue::math::greater_equal() for each corresponding pair of components from lhs and rhs. More...
 
template<typename T , int N>
vec< decltype(tue::math::equal(std::declval< T >), std::declval< T >))), N > tue::math::equal (const vec< T, N > &lhs, const vec< T, N > &rhs) noexcept
 Computes tue::math::equal() for each corresponding pair of components from lhs and rhs. More...
 
template<typename T , int N>
vec< decltype(tue::math::not_equal(std::declval< T >), std::declval< T >))), N > tue::math::not_equal (const vec< T, N > &lhs, const vec< T, N > &rhs) noexcept
 Computes tue::math::not_equal() for each corresponding pair of components from lhs and rhs. More...
 
template<typename T , typename U , int N>
decltype(std::declval< T >()*std::declval< U >()) constexpr tue::math::dot (const vec< T, N > &lhs, const vec< U, N > &rhs) noexcept
 Computes the dot product of lhs and rhs. More...
 
template<typename T , typename U >
constexpr vec3< decltype(std::declval< T >)*std::declval< U >))> tue::math::cross (const vec3< T > &lhs, const vec3< U > &rhs) noexcept
 Computes the cross product of lhs and rhs. More...
 
template<typename T , int N>
tue::math::length (const vec< T, N > &v) noexcept
 Computes the vector length of v. More...
 
template<typename T , int N>
constexpr T tue::math::length2 (const vec< T, N > &v) noexcept
 Computes the vector length squared of v. More...
 
template<typename T , int N>
tue::math::rlength (const vec< T, N > &v) noexcept
 Computes the reciprocal of the vector length of v. More...
 
template<typename T , int N>
vec< T, N > tue::math::normalize (const vec< T, N > &v) noexcept
 Computes a normalized copy of v. More...
 

Class Documentation

struct tue::is_vec_component

template<typename T>
struct tue::is_vec_component< T >

Checks if a type can be used as the component type of a vec.

Extends std::integral_constant<bool, true> for the following types and std::integral_constant<bool, false> otherwise:

  • float
  • double
  • std::int8_t
  • std::int16_t
  • std::int32_t
  • std::int64_t
  • std::uint8_t
  • std::uint16_t
  • std::uint32_t
  • std::uint64_t
  • tue::bool8
  • tue::bool16
  • tue::bool32
  • tue::bool64
  • tue::simd
Template Parameters
TThe type to check.
class tue::vec

template<typename T, int N>
class tue::vec< T, N >

An N-dimensional vector.

vec has the same size and alignment requirements as T[N].

Template Parameters
TThe component type. is_vec_component<T>value must be true.
NThe component count. Must be 2, 3, or 4.

Public Types

using component_type = T
 This vec type's component type. More...
 

Static Public Attributes

static constexpr int component_count = N
 This vec type's component count. More...
 

Constructors, Conversions, and Factory Functions

 vec () noexcept=default
 Default constructs each component. More...
 
constexpr vec (const T &x) noexcept
 Constructs each component with the same value. More...
 
constexpr vec (const T &x, const T &y) noexcept
 Constructs each component with the value of the corresponding argument. More...
 
constexpr vec (const T &x, const T &y, const T &z) noexcept
 Constructs each component with the value of the corresponding argument. More...
 
constexpr vec (const T &x, const T &y, const T &z, const T &w) noexcept
 Constructs each component with the value of the corresponding argument. More...
 
constexpr vec (const vec2< T > &xy, const T &z) noexcept
 Constructs each component with the value of the corresponding argument. More...
 
constexpr vec (const vec2< T > &xy, const T &z, const T &w) noexcept
 Constructs each component with the value of the corresponding argument. More...
 
constexpr vec (const vec3< T > &xyz, const T &w) noexcept
 Constructs each component with the value of the corresponding argument. More...
 
template<int VN, typename = std::enable_if_t<(VN greater_than N)>>
constexpr vec (const vec< T, VN > &v) noexcept
 Truncates a larger vec with the same component type. More...
 
template<typename U >
constexpr vec (const vec< U, N > &v) noexcept
 Explicitly casts another vec to a new component type. More...
 
template<typename U >
constexpr operator vec< U, N > () const noexcept
 Implicitly casts this vec to a new component type. More...
 
static constexpr vec< T, N > zero () noexcept
 Returns a vec with each component set to 0. More...
 
static constexpr vec< T, N > x_axis () noexcept
 Returns a vec with the first component set to 1 and all other components set to 0. More...
 
static constexpr vec< T, N > y_axis () noexcept
 Returns a vec with the second component set to 1 and all other components set to 0. More...
 
static constexpr vec< T, N > z_axis () noexcept
 Returns a vec with the third component set to 1 and all other components set to 0. More...
 
static constexpr vec< T, N > w_axis () noexcept
 Returns a vec with the fourth component set to 1 and all other components set to 0. More...
 

Public Member Functions

template<typename I >
constexpr const T & operator[] (const I &i) const noexcept
 Returns a reference to the component at the given index. More...
 
template<typename I >
T & operator[] (const I &i) noexcept
 Returns a reference to the component at the given index. More...
 
const T * data () const noexcept
 Returns a pointer to this vec's underlying component array. More...
 
T * data () noexcept
 Returns a pointer to this vec's underlying component array. More...
 
constexpr T x () const noexcept
 Returns a copy of this vec's first component. More...
 
constexpr T y () const noexcept
 Returns a copy of this vec's second component. More...
 
constexpr T z () const noexcept
 Returns a copy of this vec's third component. More...
 
constexpr T w () const noexcept
 Returns a copy of this vec's fourth component. More...
 
constexpr vec2< T > xy () const noexcept
 Returns a copy of this vec's first two components. More...
 
constexpr vec3< T > xyz () const noexcept
 Returns a copy of this vec's first three components. More...
 
constexpr vec4< T > xyzw () const noexcept
 Returns a copy of this vec's first four components. More...
 
void set_x (const T &x) noexcept
 Sets this vec's first component. More...
 
void set_y (const T &y) noexcept
 Sets this vec's second component. More...
 
void set_z (const T &z) noexcept
 Sets this vec's third component. More...
 
void set_w (const T &w) noexcept
 Sets this vec's fourth component. More...
 
void set_xy (const T &x, const T &y) noexcept
 Sets this vec's first two components. More...
 
void set_xy (const vec2< T > &xy) noexcept
 Sets this vec's first two components. More...
 
void set_xyz (const T &x, const T &y, const T &z) noexcept
 Sets this vec's first three components. More...
 
void set_xyz (const vec2< T > &xy, const T &z) noexcept
 Sets this vec's first three components. More...
 
void set_xyz (const vec3< T > &xyz) noexcept
 Sets this vec's first three components. More...
 
void set_xyzw (const T &x, const T &y, const T &z, const T &w) noexcept
 Sets this vec's first four components. More...
 
void set_xyzw (const vec2< T > &xy, const T &z, const T &w) noexcept
 Sets this vec's first four components. More...
 
void set_xyzw (const vec3< T > &xyz, const T &w) noexcept
 Sets this vec's first four components. More...
 
void set_xyzw (const vec4< T > &xyzw) noexcept
 Sets this vec's first four components. More...
 
constexpr T r () const noexcept
 Returns a copy of this vec's first component. More...
 
constexpr T g () const noexcept
 Returns a copy of this vec's second component. More...
 
constexpr T b () const noexcept
 Returns a copy of this vec's third component. More...
 
constexpr T a () const noexcept
 Returns a copy of this vec's fourth component. More...
 
constexpr vec2< T > rg () const noexcept
 Returns a copy of this vec's first two components. More...
 
constexpr vec3< T > rgb () const noexcept
 Returns a copy of this vec's first three components. More...
 
constexpr vec4< T > rgba () const noexcept
 Returns a copy of this vec's first four components. More...
 
void set_r (const T &r) noexcept
 Sets this vec's first component. More...
 
void set_g (const T &g) noexcept
 Sets this vec's second component. More...
 
void set_b (const T &b) noexcept
 Sets this vec's third component. More...
 
void set_a (const T &a) noexcept
 Sets this vec's fourth component. More...
 
void set_rg (const T &r, const T &g) noexcept
 Sets this vec's first two components. More...
 
void set_rg (const vec2< T > &rg) noexcept
 Sets this vec's first two components. More...
 
void set_rgb (const T &r, const T &g, const T &b) noexcept
 Sets this vec's first three components. More...
 
void set_rgb (const vec2< T > &rg, const T &b) noexcept
 Sets this vec's first three components. More...
 
void set_rgb (const vec3< T > &rgb) noexcept
 Sets this vec's first three components. More...
 
void set_rgba (const T &r, const T &g, const T &b, const T &a) noexcept
 Sets this vec's first four components. More...
 
void set_rgba (const vec2< T > &rg, const T &b, const T &a) noexcept
 Sets this vec's first four components. More...
 
void set_rgba (const vec3< T > &rgb, const T &a) noexcept
 Sets this vec's first four components. More...
 
void set_rgba (const vec4< T > &rgba) noexcept
 Sets this vec's first four components. More...
 
vec< T, N > & operator++ () noexcept
 Pre-increments each component of this vec. More...
 
vec< T, N > operator++ (int) noexcept
 Post-increments each component of this vec. More...
 
vec< T, N > & operator-- () noexcept
 Pre-decrements each component of this vec. More...
 
vec< T, N > operator-- (int) noexcept
 Post-decrements each component of this vec. More...
 
template<typename U >
std::enable_if_t< is_vec_component< U >::value, vec< T, N > & > operator+= (const U &x) noexcept
 Adds x to each component of this vec. More...
 
template<typename U >
vec< T, N > & operator+= (const vec< U, N > &v) noexcept
 Adds each component of v to the corresponding component of this vec. More...
 
template<typename U >
std::enable_if_t< is_vec_component< U >::value, vec< T, N > & > operator-= (const U &x) noexcept
 Subtracts x from each component of this vec. More...
 
template<typename U >
vec< T, N > & operator-= (const vec< U, N > &v) noexcept
 Subtracts each component of v from the corresponding component of this vec. More...
 
template<typename U >
std::enable_if_t< is_vec_component< U >::value, vec< T, N > & > operator*= (const U &x) noexcept
 Multiplies each component of this vec by x. More...
 
template<typename U >
vec< T, N > & operator*= (const vec< U, N > &v) noexcept
 Multiplies each component of this vec by the corresponding component from v. More...
 
template<typename U >
vec< T, N > & operator*= (const quat< U > &q) noexcept
 Rotates this vec by q. More...
 
template<typename U >
vec< T, N > & operator*= (const mat< U, N, N > &m) noexcept
 Matrix multiplies this vec by m. More...
 
template<typename U >
std::enable_if_t< is_vec_component< U >::value, vec< T, N > & > operator/= (const U &x) noexcept
 Divides each component of this vec by x. More...
 
template<typename U >
vec< T, N > & operator/= (const vec< U, N > &v) noexcept
 Divides each component of this vec by the corresponding component from v. More...
 
template<typename U >
std::enable_if_t< is_vec_component< U >::value, vec< T, N > & > operator%= (const U &x) noexcept
 Modulos each component of this vec by x. More...
 
template<typename U >
vec< T, N > & operator%= (const vec< U, N > &v) noexcept
 Modulos each component of this vec by the corresponding component from v. More...
 
template<typename U >
std::enable_if_t< is_vec_component< U >::value, vec< T, N > & > operator&= (const U &x) noexcept
 Bitwise ANDs each component of this vec with x. More...
 
template<typename U >
vec< T, N > & operator&= (const vec< U, N > &v) noexcept
 Bitwise ANDs each component of this vec with the corresponding component from v. More...
 
template<typename U >
std::enable_if_t< is_vec_component< U >::value, vec< T, N > & > operator|= (const U &x) noexcept
 Bitwise ORs each component of this vec with x. More...
 
template<typename U >
vec< T, N > & operator|= (const vec< U, N > &v) noexcept
 Bitwise ORs each component of this vec with the corresponding component from v. More...
 
template<typename U >
std::enable_if_t< is_vec_component< U >::value, vec< T, N > & > operator^= (const U &x) noexcept
 Bitwise XORs each component of this vec with x. More...
 
template<typename U >
vec< T, N > & operator^= (const vec< U, N > &v) noexcept
 Bitwise XORs each component of this vec with the corresponding component from v. More...
 
template<typename U >
std::enable_if_t< is_vec_component< U >::value, vec< T, N > & > operator<<= (const U &x) noexcept
 Bitwise shifts left each component of this vec by x. More...
 
template<typename U >
vec< T, N > & operator<<= (const vec< U, N > &v) noexcept
 Bitwise shifts left each component of this vec by the corresponding component from v. More...
 
template<typename U >
std::enable_if_t< is_vec_component< U >::value, vec< T, N > & > operator>>= (const U &x) noexcept
 Bitwise shifts right each component of this vec by x. More...
 
template<typename U >
vec< T, N > & operator>>= (const vec< U, N > &v) noexcept
 Bitwise shifts right each component of this vec by the corresponding component from v. More...
 

Member Typedef Documentation

template<typename T, int N>
using tue::vec< T, N >::component_type = T

This vec type's component type.

Member Data Documentation

template<typename T, int N>
constexpr int tue::vec< T, N >::component_count = N
static

This vec type's component count.

Constructor & Destructor Documentation

template<typename T, int N>
tue::vec< T, N >::vec ( )
defaultnoexcept

Default constructs each component.

template<typename T, int N>
constexpr tue::vec< T, N >::vec ( const T &  x)
inlineexplicitnoexcept

Constructs each component with the same value.

Parameters
xThe value to construct each component with.
template<typename T, int N>
constexpr tue::vec< T, N >::vec ( const T &  x,
const T &  y 
)
inlinenoexcept

Constructs each component with the value of the corresponding argument.

This overload is only available when N equals 2.

Parameters
xThe value to construct the first component with.
yThe value to construct the second component with.
template<typename T, int N>
constexpr tue::vec< T, N >::vec ( const T &  x,
const T &  y,
const T &  z 
)
inlinenoexcept

Constructs each component with the value of the corresponding argument.

This overload is only available when N equals 3.

Parameters
xThe value to construct the first component with.
yThe value to construct the second component with.
zThe value to construct the third component with.
template<typename T, int N>
constexpr tue::vec< T, N >::vec ( const T &  x,
const T &  y,
const T &  z,
const T &  w 
)
inlinenoexcept

Constructs each component with the value of the corresponding argument.

This overload is only available when N equals 4.

Parameters
xThe value to construct the first component with.
yThe value to construct the second component with.
zThe value to construct the third component with.
wThe value to construct the fourth component with.
template<typename T, int N>
constexpr tue::vec< T, N >::vec ( const vec2< T > &  xy,
const T &  z 
)
inlinenoexcept

Constructs each component with the value of the corresponding argument.

This overload is only available when N equals 3.

Parameters
xyThe values to construct the first two components with.
zThe value to construct the third component with.
template<typename T, int N>
constexpr tue::vec< T, N >::vec ( const vec2< T > &  xy,
const T &  z,
const T &  w 
)
inlinenoexcept

Constructs each component with the value of the corresponding argument.

This overload is only available when N equals 4.

Parameters
xyThe values to construct the first two components with.
zThe value to construct the third component with.
wThe value to construct the fourth component with.
template<typename T, int N>
constexpr tue::vec< T, N >::vec ( const vec3< T > &  xyz,
const T &  w 
)
inlinenoexcept

Constructs each component with the value of the corresponding argument.

This overload is only available when N equals 4.

Parameters
xyzThe values to construct the first three components with.
wThe value to construct the fourth component with.
template<typename T, int N>
template<int VN, typename = std::enable_if_t<(VN greater_than N)>>
constexpr tue::vec< T, N >::vec ( const vec< T, VN > &  v)
inlineexplicitnoexcept

Truncates a larger vec with the same component type.

Template Parameters
VNThe component count of v.
Parameters
vThe larger vec to truncate.
template<typename T, int N>
template<typename U >
constexpr tue::vec< T, N >::vec ( const vec< U, N > &  v)
inlineexplicitnoexcept

Explicitly casts another vec to a new component type.

Template Parameters
UThe component type of v.
Parameters
vThe vec to cast from.

Member Function Documentation

template<typename T, int N>
template<typename U >
constexpr tue::vec< T, N >::operator vec< U, N > ( ) const
inlinenoexcept

Implicitly casts this vec to a new component type.

Template Parameters
UThe new component type.
Returns
A new vec with the new component type.
template<typename T, int N>
static constexpr vec<T, N> tue::vec< T, N >::zero ( )
inlinestaticnoexcept

Returns a vec with each component set to 0.

Returns
A vec with each component set to 0.
template<typename T, int N>
static constexpr vec<T, N> tue::vec< T, N >::x_axis ( )
inlinestaticnoexcept

Returns a vec with the first component set to 1 and all other components set to 0.

Returns
A vec with the first component set to 1 and all other components set to 0.
template<typename T, int N>
static constexpr vec<T, N> tue::vec< T, N >::y_axis ( )
inlinestaticnoexcept

Returns a vec with the second component set to 1 and all other components set to 0.

Returns
A vec with the second component set to 1 and all other components set to 0.
template<typename T, int N>
static constexpr vec<T, N> tue::vec< T, N >::z_axis ( )
inlinestaticnoexcept

Returns a vec with the third component set to 1 and all other components set to 0.

This overload is only available when N is greater than or equal to 3.

Returns
A vec with the third component set to 1 and all other components set to 0.
template<typename T, int N>
static constexpr vec<T, N> tue::vec< T, N >::w_axis ( )
inlinestaticnoexcept

Returns a vec with the fourth component set to 1 and all other components set to 0.

This overload is only available when N is greater than or equal to 4.

Returns
A vec with the fourth component set to 1 and all other components set to 0.
template<typename T, int N>
template<typename I >
constexpr const T& tue::vec< T, N >::operator[] ( const I &  i) const
inlinenoexcept

Returns a reference to the component at the given index.

No bounds checking is performed.

Template Parameters
IThe index type.
Parameters
iThe index.
Returns
A reference to the component at the given index.
template<typename T, int N>
template<typename I >
T& tue::vec< T, N >::operator[] ( const I &  i)
inlinenoexcept

Returns a reference to the component at the given index.

No bounds checking is performed.

Template Parameters
IThe index type.
Parameters
iThe index.
Returns
A reference to the component at the given index.
template<typename T, int N>
const T* tue::vec< T, N >::data ( ) const
inlinenoexcept

Returns a pointer to this vec's underlying component array.

Returns
A pointer to this vec's underlying component array.
template<typename T, int N>
T* tue::vec< T, N >::data ( )
inlinenoexcept

Returns a pointer to this vec's underlying component array.

Returns
A pointer to this vec's underlying component array.
template<typename T, int N>
constexpr T tue::vec< T, N >::x ( ) const
inlinenoexcept

Returns a copy of this vec's first component.

Returns
A copy of this vec's first component.
template<typename T, int N>
constexpr T tue::vec< T, N >::y ( ) const
inlinenoexcept

Returns a copy of this vec's second component.

Returns
A copy of this vec's second component.
template<typename T, int N>
constexpr T tue::vec< T, N >::z ( ) const
inlinenoexcept

Returns a copy of this vec's third component.

This overload is only available when N is greater than or equal to 3.

Returns
A copy of this vec's third component.
template<typename T, int N>
constexpr T tue::vec< T, N >::w ( ) const
inlinenoexcept

Returns a copy of this vec's fourth component.

This overload is only available when N is greater than or equal to 4.

Returns
A copy of this vec's fourth component.
template<typename T, int N>
constexpr vec2<T> tue::vec< T, N >::xy ( ) const
inlinenoexcept

Returns a copy of this vec's first two components.

Returns
A copy of this vec's first two components.
template<typename T, int N>
constexpr vec3<T> tue::vec< T, N >::xyz ( ) const
inlinenoexcept

Returns a copy of this vec's first three components.

This overload is only available when N is greater than or equal to 3.

Returns
A copy of this vec's first three components.
template<typename T, int N>
constexpr vec4<T> tue::vec< T, N >::xyzw ( ) const
inlinenoexcept

Returns a copy of this vec's first four components.

This overload is only available when N is greater than or equal to 4.

Returns
A copy of this vec's first four components.
template<typename T, int N>
void tue::vec< T, N >::set_x ( const T &  x)
inlinenoexcept

Sets this vec's first component.

Parameters
xThe new value for the first component.
template<typename T, int N>
void tue::vec< T, N >::set_y ( const T &  y)
inlinenoexcept

Sets this vec's second component.

Parameters
yThe new value for the second component.
template<typename T, int N>
void tue::vec< T, N >::set_z ( const T &  z)
inlinenoexcept

Sets this vec's third component.

This overload is only available when N is greater than or equal to 3.

Parameters
zThe new value for the third component.
template<typename T, int N>
void tue::vec< T, N >::set_w ( const T &  w)
inlinenoexcept

Sets this vec's fourth component.

This overload is only available when N is greater than or equal to 4.

Parameters
wThe new value for the fourth component.
template<typename T, int N>
void tue::vec< T, N >::set_xy ( const T &  x,
const T &  y 
)
inlinenoexcept

Sets this vec's first two components.

Parameters
xThe new value for the first component.
yThe new value for the second component.
template<typename T, int N>
void tue::vec< T, N >::set_xy ( const vec2< T > &  xy)
inlinenoexcept

Sets this vec's first two components.

Parameters
xyThe new values for the first two components.
template<typename T, int N>
void tue::vec< T, N >::set_xyz ( const T &  x,
const T &  y,
const T &  z 
)
inlinenoexcept

Sets this vec's first three components.

This overload is only available when N is greater than or equal to 3.

Parameters
xThe new value for the first component.
yThe new value for the second component.
zThe new value for the third component.
template<typename T, int N>
void tue::vec< T, N >::set_xyz ( const vec2< T > &  xy,
const T &  z 
)
inlinenoexcept

Sets this vec's first three components.

This overload is only available when N is greater than or equal to 3.

Parameters
xyThe new values for the first two components.
zThe new value for the third component.
template<typename T, int N>
void tue::vec< T, N >::set_xyz ( const vec3< T > &  xyz)
inlinenoexcept

Sets this vec's first three components.

This overload is only available when N is greater than or equal to 3.

Parameters
xyzThe new values for the first three components.
template<typename T, int N>
void tue::vec< T, N >::set_xyzw ( const T &  x,
const T &  y,
const T &  z,
const T &  w 
)
inlinenoexcept

Sets this vec's first four components.

This overload is only available when N is greater than or equal to 4.

Parameters
xThe new value for the first component.
yThe new value for the second component.
zThe new value for the third component.
wThe new value for the fourth component.
template<typename T, int N>
void tue::vec< T, N >::set_xyzw ( const vec2< T > &  xy,
const T &  z,
const T &  w 
)
inlinenoexcept

Sets this vec's first four components.

This overload is only available when N is greater than or equal to 4.

Parameters
xyThe new values for the first two components.
zThe new value for the third component.
wThe new value for the fourth component.
template<typename T, int N>
void tue::vec< T, N >::set_xyzw ( const vec3< T > &  xyz,
const T &  w 
)
inlinenoexcept

Sets this vec's first four components.

This overload is only available when N is greater than or equal to 4.

Parameters
xyzThe new values for the first three components.
wThe new value for the fourth component.
template<typename T, int N>
void tue::vec< T, N >::set_xyzw ( const vec4< T > &  xyzw)
inlinenoexcept

Sets this vec's first four components.

This overload is only available when N is greater than or equal to 4.

Parameters
xyzwThe new values for the first four components.
template<typename T, int N>
constexpr T tue::vec< T, N >::r ( ) const
inlinenoexcept

Returns a copy of this vec's first component.

Returns
A copy of this vec's first component.
template<typename T, int N>
constexpr T tue::vec< T, N >::g ( ) const
inlinenoexcept

Returns a copy of this vec's second component.

Returns
A copy of this vec's second component.
template<typename T, int N>
constexpr T tue::vec< T, N >::b ( ) const
inlinenoexcept

Returns a copy of this vec's third component.

This overload is only available when N is greater than or equal to 3.

Returns
A copy of this vec's third component.
template<typename T, int N>
constexpr T tue::vec< T, N >::a ( ) const
inlinenoexcept

Returns a copy of this vec's fourth component.

This overload is only available when N is greater than or equal to 4.

Returns
A copy of this vec's fourth component.
template<typename T, int N>
constexpr vec2<T> tue::vec< T, N >::rg ( ) const
inlinenoexcept

Returns a copy of this vec's first two components.

Returns
A copy of this vec's first two components.
template<typename T, int N>
constexpr vec3<T> tue::vec< T, N >::rgb ( ) const
inlinenoexcept

Returns a copy of this vec's first three components.

This overload is only available when N is greater than or equal to 3.

Returns
A copy of this vec's first three components.
template<typename T, int N>
constexpr vec4<T> tue::vec< T, N >::rgba ( ) const
inlinenoexcept

Returns a copy of this vec's first four components.

This overload is only available when N is greater than or equal to 4.

Returns
A copy of this vec's first four components.
template<typename T, int N>
void tue::vec< T, N >::set_r ( const T &  r)
inlinenoexcept

Sets this vec's first component.

Parameters
rThe new value for the first component.
template<typename T, int N>
void tue::vec< T, N >::set_g ( const T &  g)
inlinenoexcept

Sets this vec's second component.

Parameters
gThe new value for the second component.
template<typename T, int N>
void tue::vec< T, N >::set_b ( const T &  b)
inlinenoexcept

Sets this vec's third component.

This overload is only available when N is greater than or equal to 3.

Parameters
bThe new value for the third component.
template<typename T, int N>
void tue::vec< T, N >::set_a ( const T &  a)
inlinenoexcept

Sets this vec's fourth component.

This overload is only available when N is greater than or equal to 4.

Parameters
aThe new value for the fourth component.
template<typename T, int N>
void tue::vec< T, N >::set_rg ( const T &  r,
const T &  g 
)
inlinenoexcept

Sets this vec's first two components.

Parameters
rThe new value for the first component.
gThe new value for the second component.
template<typename T, int N>
void tue::vec< T, N >::set_rg ( const vec2< T > &  rg)
inlinenoexcept

Sets this vec's first two components.

Parameters
rgThe new values for the first two components.
template<typename T, int N>
void tue::vec< T, N >::set_rgb ( const T &  r,
const T &  g,
const T &  b 
)
inlinenoexcept

Sets this vec's first three components.

This overload is only available when N is greater than or equal to 3.

Parameters
rThe new value for the first component.
gThe new value for the second component.
bThe new value for the third component.
template<typename T, int N>
void tue::vec< T, N >::set_rgb ( const vec2< T > &  rg,
const T &  b 
)
inlinenoexcept

Sets this vec's first three components.

This overload is only available when N is greater than or equal to 3.

Parameters
rgThe new values for the first two components.
bThe new value for the third component.
template<typename T, int N>
void tue::vec< T, N >::set_rgb ( const vec3< T > &  rgb)
inlinenoexcept

Sets this vec's first three components.

This overload is only available when N is greater than or equal to 3.

Parameters
rgbThe new values for the first three components.
template<typename T, int N>
void tue::vec< T, N >::set_rgba ( const T &  r,
const T &  g,
const T &  b,
const T &  a 
)
inlinenoexcept

Sets this vec's first four components.

This overload is only available when N is greater than or equal to 4.

Parameters
rThe new value for the first component.
gThe new value for the second component.
bThe new value for the third component.
aThe new value for the fourth component.
template<typename T, int N>
void tue::vec< T, N >::set_rgba ( const vec2< T > &  rg,
const T &  b,
const T &  a 
)
inlinenoexcept

Sets this vec's first four components.

This overload is only available when N is greater than or equal to 4.

Parameters
rgThe new values for the first two components.
bThe new value for the third component.
aThe new value for the fourth component.
template<typename T, int N>
void tue::vec< T, N >::set_rgba ( const vec3< T > &  rgb,
const T &  a 
)
inlinenoexcept

Sets this vec's first four components.

This overload is only available when N is greater than or equal to 4.

Parameters
rgbThe new values for the first three components.
aThe new value for the fourth component.
template<typename T, int N>
void tue::vec< T, N >::set_rgba ( const vec4< T > &  rgba)
inlinenoexcept

Sets this vec's first four components.

This overload is only available when N is greater than or equal to 4.

Parameters
rgbaThe new values for the first four components.
template<typename T, int N>
vec<T, N>& tue::vec< T, N >::operator++ ( )
inlinenoexcept

Pre-increments each component of this vec.

Returns
A reference to this vec.
template<typename T, int N>
vec<T, N> tue::vec< T, N >::operator++ ( int  )
inlinenoexcept

Post-increments each component of this vec.

Returns
A copy of this vec before being incremented.
template<typename T, int N>
vec<T, N>& tue::vec< T, N >::operator-- ( )
inlinenoexcept

Pre-decrements each component of this vec.

Returns
A reference to this vec.
template<typename T, int N>
vec<T, N> tue::vec< T, N >::operator-- ( int  )
inlinenoexcept

Post-decrements each component of this vec.

Returns
A copy of this vec before being decremented.
template<typename T, int N>
template<typename U >
std::enable_if_t<is_vec_component<U>::value, vec<T, N>&> tue::vec< T, N >::operator+= ( const U &  x)
inlinenoexcept

Adds x to each component of this vec.

Template Parameters
UThe type of parameter x.
Parameters
xThe value to add to each component of this vec.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator+= ( const vec< U, N > &  v)
inlinenoexcept

Adds each component of v to the corresponding component of this vec.

Template Parameters
UThe component type of v.
Parameters
vThe values to add to each component of this vec.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
std::enable_if_t<is_vec_component<U>::value, vec<T, N>&> tue::vec< T, N >::operator-= ( const U &  x)
inlinenoexcept

Subtracts x from each component of this vec.

Template Parameters
UThe type of parameter x.
Parameters
xThe value to subtract from each component of this vec.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator-= ( const vec< U, N > &  v)
inlinenoexcept

Subtracts each component of v from the corresponding component of this vec.

Template Parameters
UThe component type of v.
Parameters
vThe values to subtract from each component of this vec.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
std::enable_if_t<is_vec_component<U>::value, vec<T, N>&> tue::vec< T, N >::operator*= ( const U &  x)
inlinenoexcept

Multiplies each component of this vec by x.

Template Parameters
UThe type of parameter x.
Parameters
xThe value to multiply each component of this vec by.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator*= ( const vec< U, N > &  v)
inlinenoexcept

Multiplies each component of this vec by the corresponding component from v.

Template Parameters
UThe component type of v.
Parameters
vThe values to multiply each component of this vec by.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator*= ( const quat< U > &  q)
inlinenoexcept

Rotates this vec by q.

This overload is only available when N is equal to 3. The operand order might be the opposite of what you expect from other libraries. This library generally prefers compound transformations be written from left-to-right instead of right-to-left.

Template Parameters
UThe component type of q.
Parameters
qA rotation quat.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator*= ( const mat< U, N, N > &  m)
inlinenoexcept

Matrix multiplies this vec by m.

This vec is treated as a matrix with a single row.

Template Parameters
UThe component type of m.
Parameters
mA mat.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
std::enable_if_t<is_vec_component<U>::value, vec<T, N>&> tue::vec< T, N >::operator/= ( const U &  x)
inlinenoexcept

Divides each component of this vec by x.

Template Parameters
UThe type of parameter x.
Parameters
xThe value to divide each component of this vec by.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator/= ( const vec< U, N > &  v)
inlinenoexcept

Divides each component of this vec by the corresponding component from v.

Template Parameters
UThe component type of v.
Parameters
vThe values to divide each component of this vec by.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
std::enable_if_t<is_vec_component<U>::value, vec<T, N>&> tue::vec< T, N >::operator%= ( const U &  x)
inlinenoexcept

Modulos each component of this vec by x.

Template Parameters
UThe type of parameter x.
Parameters
xThe value to modulo each component of this vec by.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator%= ( const vec< U, N > &  v)
inlinenoexcept

Modulos each component of this vec by the corresponding component from v.

Template Parameters
UThe component type of v.
Parameters
vThe values to modulo each component of this vec by.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
std::enable_if_t<is_vec_component<U>::value, vec<T, N>&> tue::vec< T, N >::operator&= ( const U &  x)
inlinenoexcept

Bitwise ANDs each component of this vec with x.

Template Parameters
UThe type of parameter x.
Parameters
xThe value to bitwise AND each component of this vec with.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator&= ( const vec< U, N > &  v)
inlinenoexcept

Bitwise ANDs each component of this vec with the corresponding component from v.

Template Parameters
UThe component type of v.
Parameters
vThe values to bitwise AND each component of this vec with.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
std::enable_if_t<is_vec_component<U>::value, vec<T, N>&> tue::vec< T, N >::operator|= ( const U &  x)
inlinenoexcept

Bitwise ORs each component of this vec with x.

Template Parameters
UThe type of parameter x.
Parameters
xThe value to bitwise OR each component of this vec with.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator|= ( const vec< U, N > &  v)
inlinenoexcept

Bitwise ORs each component of this vec with the corresponding component from v.

Template Parameters
UThe component type of v.
Parameters
vThe values to bitwise OR each component of this vec with.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
std::enable_if_t<is_vec_component<U>::value, vec<T, N>&> tue::vec< T, N >::operator^= ( const U &  x)
inlinenoexcept

Bitwise XORs each component of this vec with x.

Template Parameters
UThe type of parameter x.
Parameters
xThe value to bitwise XOR each component of this vec with.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator^= ( const vec< U, N > &  v)
inlinenoexcept

Bitwise XORs each component of this vec with the corresponding component from v.

Template Parameters
UThe component type of v.
Parameters
vThe values to bitwise XOR each component of this vec with.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
std::enable_if_t<is_vec_component<U>::value, vec<T, N>&> tue::vec< T, N >::operator<<= ( const U &  x)
inlinenoexcept

Bitwise shifts left each component of this vec by x.

Template Parameters
UThe type of parameter x.
Parameters
xThe value to bitwise shift left each component of this vec by.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator<<= ( const vec< U, N > &  v)
inlinenoexcept

Bitwise shifts left each component of this vec by the corresponding component from v.

Template Parameters
UThe component type of v.
Parameters
vThe values to bitwise shift left each component of this vec by.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
std::enable_if_t<is_vec_component<U>::value, vec<T, N>&> tue::vec< T, N >::operator>>= ( const U &  x)
inlinenoexcept

Bitwise shifts right each component of this vec by x.

Template Parameters
UThe type of parameter x.
Parameters
xThe value to bitwise shift right each component of this vec by.
Returns
A reference to this vec.
template<typename T, int N>
template<typename U >
vec<T, N>& tue::vec< T, N >::operator>>= ( const vec< U, N > &  v)
inlinenoexcept

Bitwise shifts right each component of this vec by the corresponding component from v.

Template Parameters
UThe component type of v.
Parameters
vThe values to bitwise shift right each component of this vec by.
Returns
A reference to this vec.

Typedef Documentation

template<typename T >
using tue::vec2 = typedef vec<T, 2>

A 2-dimensional vector.

Template Parameters
TThe component type.
template<typename T >
using tue::vec3 = typedef vec<T, 3>

A 3-dimensional vector.

Template Parameters
TThe component type.
template<typename T >
using tue::vec4 = typedef vec<T, 4>

A 4-dimensional vector.

Template Parameters
TThe component type.
using tue::fvec2 = typedef vec2<float>

A 2-dimensional vector with float components.

using tue::fvec3 = typedef vec3<float>

A 3-dimensional vector with float components.

using tue::fvec4 = typedef vec4<float>

A 4-dimensional vector with float components.

using tue::dvec2 = typedef vec2<double>

A 2-dimensional vector with double components.

using tue::dvec3 = typedef vec3<double>

A 3-dimensional vector with double components.

using tue::dvec4 = typedef vec4<double>

A 4-dimensional vector with double components.

using tue::ivec2 = typedef vec2<int>

A 2-dimensional vector with int components.

using tue::ivec3 = typedef vec3<int>

A 3-dimensional vector with int components.

using tue::ivec4 = typedef vec4<int>

A 4-dimensional vector with int components.

using tue::uvec2 = typedef vec2<unsigned int>

A 2-dimensional vector with unsigned int components.

using tue::uvec3 = typedef vec3<unsigned int>

A 3-dimensional vector with unsigned int components.

using tue::uvec4 = typedef vec4<unsigned int>

A 4-dimensional vector with unsigned int components.

Function Documentation

template<typename T , int N>
constexpr vec<decltype(+std::declval<T>)), N> tue::operator+ ( const vec< T, N > &  v)
inlinenoexcept

Computes the unary plus of each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
The unary plus of each component of v.
template<typename T , int N>
constexpr vec<decltype(-std::declval<T>)), N> tue::operator- ( const vec< T, N > &  v)
inlinenoexcept

Computes the unary minus of each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
The unary minus of each component of v.
template<typename T , int N>
constexpr vec<decltype(~std::declval<T>)), N> tue::operator~ ( const vec< T, N > &  v)
inlinenoexcept

Computes the bitwise NOT of each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
The bitwise NOT of each component of v.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<T>::value, vec<decltype(std::declval<T>) + std::declval<U>)), N> > tue::operator+ ( const T &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the sums of lhs and each component of rhs.

Template Parameters
TThe type of parameter lhs.
UThe component type of rhs.
NThe component count of rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The sums of lhs and each component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<U>::value, vec<decltype(std::declval<T>) + std::declval<U>)), N> > tue::operator+ ( const vec< T, N > &  lhs,
const U &  rhs 
)
inlinenoexcept

Computes the sums of each component of lhs and rhs.

Template Parameters
TThe component type of lhs.
UThe type of parameter rhs.
NThe component count of lhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The sums of each component of lhs and rhs.
template<typename T , typename U , int N>
constexpr vec<decltype(std::declval<T>) + std::declval<U>)), N> tue::operator+ ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the sums of each component of lhs and each corresponding component of rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The sums of each component of lhs and each corresponding component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<T>::value, vec<decltype(std::declval<T>) - std::declval<U>)), N> > tue::operator- ( const T &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the differences between lhs and each component of rhs.

Template Parameters
TThe type of parameter lhs.
UThe component type of rhs.
NThe component count of rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The differences between lhs and each component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<U>::value, vec<decltype(std::declval<T>) - std::declval<U>)), N> > tue::operator- ( const vec< T, N > &  lhs,
const U &  rhs 
)
inlinenoexcept

Computes the differences between each component of lhs and rhs.

Template Parameters
TThe component type of lhs.
UThe type of parameter rhs.
NThe component count of lhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The differences between each component of lhs and rhs.
template<typename T , typename U , int N>
constexpr vec<decltype(std::declval<T>) - std::declval<U>)), N> tue::operator- ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the differences between each component of lhs and each corresponding component of rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The differences between each component of lhs and each corresponding component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<T>::value, vec<decltype(std::declval<T>) * std::declval<U>)), N> > tue::operator* ( const T &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the products of lhs and each component of rhs.

Template Parameters
TThe type of parameter lhs.
UThe component type of rhs.
NThe component count of rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The products of lhs and each component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<U>::value, vec<decltype(std::declval<T>) * std::declval<U>)), N> > tue::operator* ( const vec< T, N > &  lhs,
const U &  rhs 
)
inlinenoexcept

Computes the products of each component of lhs and rhs.

Template Parameters
TThe component type of lhs.
UThe type of parameter rhs.
NThe component count of lhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The products of each component of lhs and rhs.
template<typename T , typename U , int N>
constexpr vec<decltype(std::declval<T>) * std::declval<U>)), N> tue::operator* ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the products of each component of lhs and each corresponding component of rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The products of each component of lhs and each corresponding component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<T>::value, vec<decltype(std::declval<T>) / std::declval<U>)), N> > tue::operator/ ( const T &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the quotients of lhs over each component of rhs.

Template Parameters
TThe type of parameter lhs.
UThe component type of rhs.
NThe component count of rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The quotients of lhs over each component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<U>::value, vec<decltype(std::declval<T>) / std::declval<U>)), N> > tue::operator/ ( const vec< T, N > &  lhs,
const U &  rhs 
)
inlinenoexcept

Computes the quotients of each component of lhs over rhs.

Template Parameters
TThe component type of lhs.
UThe type of parameter rhs.
NThe component count of lhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The quotients of each component of lhs over rhs.
template<typename T , typename U , int N>
constexpr vec<decltype(std::declval<T>) / std::declval<U>)), N> tue::operator/ ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the quotients of each component of lhs over each corresponding component of rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The quotients of each component of lhs over each corresponding component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<T>::value, vec<decltype(std::declval<T>) % std::declval<U>)), N> > tue::operator% ( const T &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the modulos of lhs over each component of rhs.

Template Parameters
TThe type of parameter lhs.
UThe component type of rhs.
NThe component count of rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The modulos of lhs over each component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<U>::value, vec<decltype(std::declval<T>) % std::declval<U>)), N> > tue::operator% ( const vec< T, N > &  lhs,
const U &  rhs 
)
inlinenoexcept

Computes the modulos of each component of lhs over rhs.

Template Parameters
TThe component type of lhs.
UThe type of parameter rhs.
NThe component count of lhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The modulos of each component of lhs over rhs.
template<typename T , typename U , int N>
constexpr vec<decltype(std::declval<T>) % std::declval<U>)), N> tue::operator% ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the modulos of each component of lhs over each corresponding component of rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The modulos of each component of lhs over each corresponding component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<T>::value, vec<decltype(std::declval<T>) & std::declval<U>)), N> > tue::operator& ( const T &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the bitwise AND of lhs and each component of rhs.

Template Parameters
TThe type of parameter lhs.
UThe component type of rhs.
NThe component count of rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise AND of lhs and each component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<U>::value, vec<decltype(std::declval<T>) & std::declval<U>)), N> > tue::operator& ( const vec< T, N > &  lhs,
const U &  rhs 
)
inlinenoexcept

Computes the bitwise AND of each component of lhs and rhs.

Template Parameters
TThe component type of lhs.
UThe type of parameter rhs.
NThe component count of lhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise AND of each component of lhs and rhs.
template<typename T , typename U , int N>
constexpr vec<decltype(std::declval<T>) & std::declval<U>)), N> tue::operator& ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the bitwise AND of each component of lhs and each corresponding component of rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise AND of each component of lhs and each corresponding component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<T>::value, vec<decltype(std::declval<T>) | std::declval<U>)), N> > tue::operator| ( const T &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the bitwise OR of lhs and each component of rhs.

Template Parameters
TThe type of parameter lhs.
UThe component type of rhs.
NThe component count of rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise OR of lhs and each component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<U>::value, vec<decltype(std::declval<T>) | std::declval<U>)), N> > tue::operator| ( const vec< T, N > &  lhs,
const U &  rhs 
)
inlinenoexcept

Computes the bitwise OR of each component of lhs and rhs.

Template Parameters
TThe component type of lhs.
UThe type of parameter rhs.
NThe component count of lhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise OR of each component of lhs and rhs.
template<typename T , typename U , int N>
constexpr vec<decltype(std::declval<T>) | std::declval<U>)), N> tue::operator| ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the bitwise OR of each component of lhs and each corresponding component of rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise OR of each component of lhs and each corresponding component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<T>::value, vec<decltype(std::declval<T>) ^ std::declval<U>)), N> > tue::operator^ ( const T &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the bitwise XOR of lhs and each component of rhs.

Template Parameters
TThe type of parameter lhs.
UThe component type of rhs.
NThe component count of rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise XOR of lhs and each component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<U>::value, vec<decltype(std::declval<T>) ^ std::declval<U>)), N> > tue::operator^ ( const vec< T, N > &  lhs,
const U &  rhs 
)
inlinenoexcept

Computes the bitwise XOR of each component of lhs and rhs.

Template Parameters
TThe component type of lhs.
UThe type of parameter rhs.
NThe component count of lhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise XOR of each component of lhs and rhs.
template<typename T , typename U , int N>
constexpr vec<decltype(std::declval<T>) ^ std::declval<U>)), N> tue::operator^ ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the bitwise XOR of each component of lhs and each corresponding component of rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise XOR of each component of lhs and each corresponding component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<T>::value, vec<decltype(std::declval<T>) shift_left std::declval<U>)), N> > tue::operator<< ( const T &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the bitwise shifts left of lhs by each component of rhs.

Template Parameters
TThe type of parameter lhs.
UThe component type of rhs.
NThe component count of rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise shifts left of lhs by each component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<U>::value, vec<decltype(std::declval<T>) shift_left std::declval<U>)), N> > tue::operator<< ( const vec< T, N > &  lhs,
const U &  rhs 
)
inlinenoexcept

Computes the bitwise shifts left of each component of lhs by rhs.

Template Parameters
TThe component type of lhs.
UThe type of parameter rhs.
NThe component count of lhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise shifts left of each component of lhs by rhs.
template<typename T , typename U , int N>
constexpr vec<decltype(std::declval<T>) shift_left std::declval<U>)), N> tue::operator<< ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the bitwise shifts left of each component of lhs by each corresponding component of rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise shifts left of each component of lhs by each corresponding component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<T>::value, vec<decltype(std::declval<T>) shift_right std::declval<U>)), N> > tue::operator>> ( const T &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the bitwise shifts right of lhs by each component of rhs.

Template Parameters
TThe type of parameter lhs.
UThe component type of rhs.
NThe component count of rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise shifts right of lhs by each component of rhs.
template<typename T , typename U , int N>
constexpr std::enable_if_t< is_vec_component<U>::value, vec<decltype(std::declval<T>) shift_right std::declval<U>)), N> > tue::operator>> ( const vec< T, N > &  lhs,
const U &  rhs 
)
inlinenoexcept

Computes the bitwise shifts right of each component of lhs by rhs.

Template Parameters
TThe component type of lhs.
UThe type of parameter rhs.
NThe component count of lhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise shifts right of each component of lhs by rhs.
template<typename T , typename U , int N>
constexpr vec<decltype(std::declval<T>) shift_right std::declval<U>)), N> tue::operator>> ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the bitwise shifts right of each component of lhs by each corresponding component of rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The bitwise shifts right of each component of lhs by each corresponding component of rhs.
template<typename T , typename U , int N>
constexpr bool tue::operator== ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Determines whether or not two vec's compare equal.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
true if all the corresponding pairs of components compare equal and false otherwise.
template<typename T , typename U , int N>
constexpr bool tue::operator!= ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Determines whether or not two vec's compare not equal.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
true if at least one of the corresponding pairs of components compares not equal and false otherwise.
template<typename T , int N>
vec<T, N> tue::math::sin ( const vec< T, N > &  v)
inlinenoexcept

Computes tue::math::sin() for each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
tue::math::sin() for each component of v.
template<typename T , int N>
vec<T, N> tue::math::cos ( const vec< T, N > &  v)
inlinenoexcept

Computes tue::math::cos() for each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
tue::math::cos() for each component of v.
template<typename T , int N>
void tue::math::sincos ( const vec< T, N > &  v,
vec< T, N > &  sin_out,
vec< T, N > &  cos_out 
)
inlinenoexcept

Computes tue::math::sincos() for each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
sin_outA reference to the vec to store the sin() results in.
cos_outA reference to the vec to store the cos() results in.
template<typename T , int N>
vec<T, N> tue::math::exp ( const vec< T, N > &  v)
inlinenoexcept

Computes tue::math::exp() for each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
tue::math::exp() for each component of v.
template<typename T , int N>
vec<T, N> tue::math::log ( const vec< T, N > &  v)
inlinenoexcept

Computes tue::math::log() for each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
tue::math::log() for each component of v.
template<typename T , int N>
vec<T, N> tue::math::abs ( const vec< T, N > &  v)
inlinenoexcept

Computes tue::math::abs() for each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
tue::math::abs() for each component of v.
template<typename T , int N>
vec<T, N> tue::math::pow ( const vec< T, N > &  bases,
const vec< T, N > &  exponents 
)
inlinenoexcept

Computes tue::math::pow() for each component of bases and each corresponding component of exponents.

Template Parameters
TThe component type of both bases and exponents.
NThe component count of both bases and exponents.
Parameters
basesThe bases.
exponentsThe exponents.
Returns
tue::math::pow() for each component of bases and each corresponding component of exponents.
template<typename T , int N>
vec<T, N> tue::math::recip ( const vec< T, N > &  v)
inlinenoexcept

Computes tue::math::recip() for each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
tue::math::recip() for each component of v.
template<typename T , int N>
vec<T, N> tue::math::sqrt ( const vec< T, N > &  v)
inlinenoexcept

Computes tue::math::sqrt() for each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
tue::math::sqrt() for each component of v.
template<typename T , int N>
vec<T, N> tue::math::rsqrt ( const vec< T, N > &  v)
inlinenoexcept

Computes tue::math::rsqrt() for each component of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
tue::math::rsqrt() for each component of v.
template<typename T , int N>
vec<T, N> tue::math::min ( const vec< T, N > &  v1,
const vec< T, N > &  v2 
)
inlinenoexcept

Computes tue::math::min() for each corresponding pair of components from v1 and v2.

Template Parameters
TThe component type of both v1 and v2.
NThe component count of both v1 and v2.
Parameters
v1A vec.
v2Another vec.
Returns
tue::math::min() for each corresponding pair of components from v1 and v2.
template<typename T , int N>
vec<T, N> tue::math::max ( const vec< T, N > &  v1,
const vec< T, N > &  v2 
)
inlinenoexcept

Computes tue::math::max() for each corresponding pair of components from v1 and v2.

Template Parameters
TThe component type of both v1 and v2.
NThe component count of both v1 and v2.
Parameters
v1A vec.
v2Another vec.
Returns
tue::math::max() for each corresponding pair of components from v1 and v2.
template<typename T , typename U , int N>
vec<U, N> tue::math::mask ( const vec< T, N > &  conditions,
const vec< U, N > &  values 
)
inlinenoexcept

Computes tue::math::mask() for each corresponding pair of components from conditions and values.

Template Parameters
TThe component type of conditions.
UThe component type of values.
NThe component count of both conditions and values.
Parameters
conditionsA vec.
valuesAnother vec.
Returns
tue::math::mask() for each corresponding pair of components from conditions and values.
template<typename T , typename U , int N>
vec<U, N> tue::math::select ( const vec< T, N > &  conditions,
const vec< U, N > &  values,
const vec< U, N > &  otherwise 
)
inlinenoexcept

Computes tue::math::select() for each corresponding trio of components from conditions, values, and otherwise.

Template Parameters
TThe component type of conditions.
UThe component type of both values and otherwise.
NThe component count of all three parameters.
Parameters
conditionsA vec.
valuesAnother vec.
otherwiseAnother vec.
Returns
tue::math::select() for each corresponding trio of components from conditions, values, and otherwise.
template<typename T , int N>
vec< decltype(tue::math::less( std::declval<T>), std::declval<T>))), N> tue::math::less ( const vec< T, N > &  lhs,
const vec< T, N > &  rhs 
)
inlinenoexcept

Computes tue::math::less() for each corresponding pair of components from lhs and rhs.

Template Parameters
TThe component type of both lhs and rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
tue::math::less() for each corresponding pair of components from lhs and rhs.
template<typename T , int N>
vec< decltype(tue::math::less_equal( std::declval<T>), std::declval<T>))), N> tue::math::less_equal ( const vec< T, N > &  lhs,
const vec< T, N > &  rhs 
)
inlinenoexcept

Computes tue::math::less_equal() for each corresponding pair of components from lhs and rhs.

Template Parameters
TThe component type of both lhs and rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
tue::math::less_equal() for each corresponding pair of components from lhs and rhs.
template<typename T , int N>
vec< decltype(tue::math::greater( std::declval<T>), std::declval<T>))), N> tue::math::greater ( const vec< T, N > &  lhs,
const vec< T, N > &  rhs 
)
inlinenoexcept

Computes tue::math::greater() for each corresponding pair of components from lhs and rhs.

Template Parameters
TThe component type of both lhs and rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
tue::math::greater() for each corresponding pair of components from lhs and rhs.
template<typename T , int N>
vec< decltype(tue::math::greater_equal( std::declval<T>), std::declval<T>))), N> tue::math::greater_equal ( const vec< T, N > &  lhs,
const vec< T, N > &  rhs 
)
inlinenoexcept

Computes tue::math::greater_equal() for each corresponding pair of components from lhs and rhs.

Template Parameters
TThe component type of both lhs and rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
tue::math::greater_equal() for each corresponding pair of components from lhs and rhs.
template<typename T , int N>
vec< decltype(tue::math::equal( std::declval<T>), std::declval<T>))), N> tue::math::equal ( const vec< T, N > &  lhs,
const vec< T, N > &  rhs 
)
inlinenoexcept

Computes tue::math::equal() for each corresponding pair of components from lhs and rhs.

Template Parameters
TThe component type of both lhs and rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
tue::math::equal() for each corresponding pair of components from lhs and rhs.
template<typename T , int N>
vec< decltype(tue::math::not_equal( std::declval<T>), std::declval<T>))), N> tue::math::not_equal ( const vec< T, N > &  lhs,
const vec< T, N > &  rhs 
)
inlinenoexcept

Computes tue::math::not_equal() for each corresponding pair of components from lhs and rhs.

Template Parameters
TThe component type of both lhs and rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
tue::math::not_equal() for each corresponding pair of components from lhs and rhs.
template<typename T , typename U , int N>
decltype(std::declval<T>() * std::declval<U>()) constexpr tue::math::dot ( const vec< T, N > &  lhs,
const vec< U, N > &  rhs 
)
inlinenoexcept

Computes the dot product of lhs and rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
NThe component count of both lhs and rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The dot product of lhs and rhs.
template<typename T , typename U >
constexpr vec3<decltype(std::declval<T>) * std::declval<U>))> tue::math::cross ( const vec3< T > &  lhs,
const vec3< U > &  rhs 
)
inlinenoexcept

Computes the cross product of lhs and rhs.

Template Parameters
TThe component type of lhs.
UThe component type of rhs.
Parameters
lhsThe left-hand side operand.
rhsThe right-hand side operand.
Returns
The cross product of lhs and rhs.
template<typename T , int N>
T tue::math::length ( const vec< T, N > &  v)
inlinenoexcept

Computes the vector length of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
The vector length of v.
template<typename T , int N>
constexpr T tue::math::length2 ( const vec< T, N > &  v)
inlinenoexcept

Computes the vector length squared of v.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
The vector length squared of v.
template<typename T , int N>
T tue::math::rlength ( const vec< T, N > &  v)
inlinenoexcept

Computes the reciprocal of the vector length of v.

If the vector length of v equals 0, behavior is undefined.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
The reciprocal of the vector length of v.
template<typename T , int N>
vec<T, N> tue::math::normalize ( const vec< T, N > &  v)
inlinenoexcept

Computes a normalized copy of v.

If the vector length of v equals 0, behavior is undefined.

Template Parameters
TThe component type of v.
NThe component count of v.
Parameters
vA vec.
Returns
A normalized copy of v.