OGLplus  (0.59.0) a C++ wrapper for rendering APIs

eagine::math::vector< T, N, V > Struct Template Reference

Basic N-dimensional vector implementation template. More...

#include <eagine/math/vector.hpp>

Public Types

using scalar_type = scalar< T, N, V >
 Related scalar type.
 
using value_type = T
 Element value type.
 
using is_vectorized = vect::has_vect_data_t< T, N, V >
 Indicates if the implementation uses SIMD extensions.
 
using vector_param = const vector &
 vector function parameter type.
 
using scalar_param = const scalar_type &
 scalar function parameter type.
 

Public Member Functions

constexpr auto operator[] (int pos) const noexcept
 Subscript operator.
 
template<int M = N>
constexpr auto x () const noexcept -> std::enable_if_t<(M > 0), T >
 Returns the x-coordinate value. More...
 
template<int M = N>
constexpr auto y () const noexcept -> std::enable_if_t<(M > 1), T >
 Returns the y-coordinate value. More...
 
template<int M = N>
constexpr auto z () const noexcept -> std::enable_if_t<(M > 2), T >
 Returns the z-coordinate value. More...
 
template<int M = N>
constexpr auto w () const noexcept -> std::enable_if_t<(M > 3), T >
 Returns the w-coordinate value. More...
 
auto operator+= (vector_param a) noexcept -> auto &
 Addition operator.
 
auto operator-= (vector_param a) noexcept -> auto &
 Subtraction operator.
 
auto operator*= (vector_param a) noexcept -> auto &
 Multiplication operator.
 
auto operator*= (scalar_param c) noexcept -> auto &
 Multiplication by scalar operator.
 
auto operator*= (T c) noexcept -> auto &
 Multiplication by constant operator.
 

Static Public Member Functions

static auto zero () noexcept
 Creates a new zero vector instance.
 
static auto fill (T v) noexcept
 Creates a zero vector instance with all elements set to v.
 
template<int I>
static auto axis () noexcept
 Creates an unit axis vector for the I-th dimension. More...
 
template<int I>
static auto axis (T v) noexcept
 Creates an axis vector for the I-th dimension with specified length. More...
 
static auto axis (int i, T v) noexcept
 Creates an axis vector for the i-th dimension with specified length. More...
 
template<typename... P, typename = std::enable_if_t<(N > 1) && (sizeof...(P) == N)>>
static constexpr auto make (P &&... p) noexcept
 Creates vector instance with the specified elements.
 
template<typename P , int M, bool W, typename = std::enable_if_t<(!std::is_same_v<T, P> || (N != M) || (V != W))>>
static constexpr auto from (const vector< P, M, W > &v, T d=T(0)) noexcept
 Creates vector instance from vector of another dimension. More...
 
template<typename P , int M, bool W>
static constexpr auto from (const vector< P, M, W > &v, const vector< T, N - M, W > &u) noexcept
 Creates vector instance from two other vectors.
 
static auto from (const T *dt, span_size_t sz) noexcept
 Creates vector instance from data pointer and length.
 
static auto from (const T *dt, span_size_t sz, T fv) noexcept
 Creates vector instance from data pointer, length and additional value.
 

Friends

constexpr friend auto operator+ (vector_param a) noexcept
 Unary plus operator.
 
constexpr friend auto operator- (vector_param a) noexcept
 Negation operator.
 
constexpr friend auto operator+ (vector_param a, vector_param b) noexcept
 Addition operator.
 
constexpr friend auto operator- (vector_param a, vector_param b) noexcept
 Subtraction operator.
 
constexpr friend auto operator* (vector_param a, vector_param b) noexcept
 Multiplication operator.
 
constexpr friend auto operator* (scalar_param c, vector_param a) noexcept
 Multiplication by scalar operator.
 
constexpr friend auto operator* (vector_param a, scalar_param c) noexcept
 Multiplication by scalar operator.
 
constexpr friend auto operator* (T c, vector_param a) noexcept
 Multiplication by constant operator.
 
constexpr friend auto operator* (vector_param a, T c) noexcept
 Multiplication by constant operator.
 
constexpr friend auto operator/ (vector_param a, vector_param b) noexcept
 Division operator.
 
constexpr friend auto operator/ (scalar_param c, vector_param a) noexcept
 Scalar division operator.
 
constexpr friend auto operator/ (vector_param a, scalar_param c) noexcept
 Division by scalar operator.
 
constexpr friend auto operator/ (vector_param a, T c) noexcept
 Division by constant operator.
 
constexpr friend auto operator/ (T c, vector_param a) noexcept
 Constant division operator.
 

Detailed Description

template<typename T, int N, bool V>
struct eagine::math::vector< T, N, V >

Basic N-dimensional vector implementation template.

See also
tvec
Note
This is a base class, typically tvec should be used in client code.

Member Function Documentation

◆ axis() [1/3]

template<typename T , int N, bool V>
template<int I>
static auto eagine::math::vector< T, N, V >::axis ( )
inlinestaticnoexcept

Creates an unit axis vector for the I-th dimension.

Precondition
I < N

◆ axis() [2/3]

template<typename T , int N, bool V>
static auto eagine::math::vector< T, N, V >::axis ( int  i,
v 
)
inlinestaticnoexcept

Creates an axis vector for the i-th dimension with specified length.

Precondition
i < N

◆ axis() [3/3]

template<typename T , int N, bool V>
template<int I>
static auto eagine::math::vector< T, N, V >::axis ( v)
inlinestaticnoexcept

Creates an axis vector for the I-th dimension with specified length.

Precondition
I < N

◆ from()

template<typename T , int N, bool V>
template<typename P , int M, bool W, typename = std::enable_if_t<(!std::is_same_v<T, P> || (N != M) || (V != W))>>
static constexpr auto eagine::math::vector< T, N, V >::from ( const vector< P, M, W > &  v,
d = T(0) 
)
inlinestaticconstexprnoexcept

Creates vector instance from vector of another dimension.

Parameters
dspecifies the value for additional elements if M < N.

Referenced by eagine::math::basic_sphere< gl_types::float_type, math_use_simd >::basic_sphere(), eagine::math::basic_sphere< gl_types::float_type, math_use_simd >::center(), and eagine::math::tvec< gl_types::float_type, 3 >::tvec().

◆ w()

template<typename T , int N, bool V>
template<int M = N>
constexpr auto eagine::math::vector< T, N, V >::w ( ) const -> std::enable_if_t<(M > 3), T>
inlineconstexprnoexcept

Returns the w-coordinate value.

Precondition
N >= 4

◆ x()

template<typename T , int N, bool V>
template<int M = N>
constexpr auto eagine::math::vector< T, N, V >::x ( ) const -> std::enable_if_t<(M > 0), T>
inlineconstexprnoexcept

Returns the x-coordinate value.

Precondition
N >= 1

◆ y()

template<typename T , int N, bool V>
template<int M = N>
constexpr auto eagine::math::vector< T, N, V >::y ( ) const -> std::enable_if_t<(M > 1), T>
inlineconstexprnoexcept

Returns the y-coordinate value.

Precondition
N >= 2

◆ z()

template<typename T , int N, bool V>
template<int M = N>
constexpr auto eagine::math::vector< T, N, V >::z ( ) const -> std::enable_if_t<(M > 2), T>
inlineconstexprnoexcept

Returns the z-coordinate value.

Precondition
N >= 3

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

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).