API Documentation
Loading...
Searching...
No Matches
Vector< t_dims, t_type > Class Template Reference

A fixed-size array with better performance compared to dynamic containers. More...

#include <Vector.hpp>

Inheritance diagram for Vector< t_dims, t_type >:
[legend]

Public Member Functions

template<class t_new_type >
constexpr Vector< t_dims, t_new_type > as () const
 
template<uint01 t_new_dim, class t_new_type >
constexpr Vector< t_new_dim, t_new_type > as () const
 
template<uint01 t_new_dim, class t_new_type >
constexpr Vector< t_new_dim, t_new_type > as (t_new_type extra_fill_value) const
 
template<LocationValues t_max_min>
constexpr uint01 dimensionalIndex () const
 
template<LocationValues t_max_min>
constexpr t_type dimensionalValue () const
 
template<class t_magnitude_type = t_type>
constexpr t_magnitude_type magnitude () const
 
constexpr t_type magnitudeSquared () const
 
template<class t_norm_type = t_type>
constexpr Vector< t_dims, t_norm_type > normalized (Vector< t_dims, t_norm_type > value_if_nan=Constant< Vector< t_dims, t_norm_type > >::Invalid) const
 
template<uint01 tdims = t_dims, typename = typename std::enable_if<tdims == 1>::type>
constexpr operator const t_type & () const
 
template<uint01 tdims = t_dims, typename = typename std::enable_if<tdims == 1>::type>
constexpr operator t_type & ()
 
constexpr Vector< t_dims, t_type > operator- () const
 
constexpr Vector< t_dims, t_type > & operator= (const t_type &scaler)
 
constexpr const t_type & operator[] (const uint01 dimension_index) const
 
constexpr t_type & operator[] (uint01 dimension_index)
 
constexpr t_type product () const
 
constexpr t_type sum () const
 
constexpr Vector () noexcept
 
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &prefix, typename std::enable_if< tdims >=2, const Vector< t_dims - 1, t_type > & >::type vector)
 
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &prefix_a, const t_type &prefix_b, typename std::enable_if< tdims >=3, const Vector< tdims - 1, t_type > & >::type vector)
 
constexpr Vector (const t_type &scaler) noexcept
 
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &x, const t_type &y, const t_type &z, const t_type &w, const t_type &v, const t_type &u, const t_type &t, const t_type &s, typename std::enable_if< tdims==9, const t_type & >::type r)
 
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &x, const t_type &y, const t_type &z, const t_type &w, const t_type &v, typename std::enable_if< tdims==6, const t_type & >::type u)
 
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &x, const t_type &y, const t_type &z, const t_type &w, typename std::enable_if< tdims==5, const t_type & >::type v)
 
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &x, const t_type &y, const t_type &z, typename std::enable_if< tdims==4, const t_type & >::type w)
 
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &x, const t_type &y, const typename std::enable_if< tdims==3, const t_type & >::type z)
 
template<uint01 tdims = t_dims>
constexpr Vector (const t_type &x, typename std::enable_if< tdims==2, const t_type & >::type y)
 
constexpr Vector (const t_type(&vector)[t_dims])
 
template<uint01 tdims = t_dims>
constexpr Vector (const Vector< getMax(tdims - 2, 0), t_type > &vector, const t_type &suffix_a, typename std::enable_if< tdims >=3, const t_type & >::type suffix_b)
 
template<class t_vec_type >
constexpr Vector (const Vector< t_dims, t_vec_type > &vector) noexcept
 
template<uint01 tdims = t_dims>
constexpr Vector (const Vector< tdims - 1, t_type > &vector, typename std::enable_if< tdims >=2, const t_type & >::type suffix)
 

Static Public Member Functions

static constexpr uint01 NumberOfDimensions ()
 
static constexpr t_type Type ()
 

Protected Attributes

t_type m_values [t_dims]
 

Detailed Description

template<uint01 t_dims, class t_type>
class NDEVR::Vector< t_dims, t_type >

A fixed-size array with better performance compared to dynamic containers.


Class: Vector

An element of a vector space. An element of the real coordinate space Rn basis vector, one of a set of vectors (a "basis") that, in linear combination, can represent every vector in a given vector space column vector or row vector, a one-dimensional matrix often representing the solution of a system of linear equations coordinate vector, in linear algebra, an explicit representation of an element of any abstract vector space. Used as the basis for Vertex class, Ray class, Point class etc. Simply stores x,y,z etc in linear memory.

t_dims: The number of dimensions used in a vector. t_type: The numerical type used to store the value in each dimension. This may be a bool, float, integer, angle, or even another vector for multidimensional groupings.

Author: Tyler Parke

Date: 2017-09-13

Constructor & Destructor Documentation

◆ Vector() [1/14]

template<uint01 t_dims, class t_type >
Vector ( )
inlineconstexprnoexcept

◆ Vector() [2/14]

template<uint01 t_dims, class t_type >
template<class t_vec_type >
Vector ( const Vector< t_dims, t_vec_type > & vector)
inlineexplicitconstexprnoexcept

Copy constructor.

Author: Tyler Parke

Date: 2017-11-13

Parameters: vector - The vector to copy to this vector.

◆ Vector() [3/14]

template<uint01 t_dims, class t_type >
Vector ( const t_type & scaler)
inlineexplicitconstexprnoexcept

Sets values in each dimension to the value in the passed in scaler

Author: Tyler Parke

Date: 2017-09-13

Parameters: scaler - The scaler to set all dimensions to.

◆ Vector() [4/14]

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims>
Vector ( const t_type & x,
typename std::enable_if< tdims==2, const t_type & >::type y )
inlineconstexpr

Sets values in each dimension to the respective value in the passed in scaler. Note the Vector must be 2 dimensions to use this function.

Author: Tyler Parke

Date: 2017-09-13

Parameters: x - The scaler to set the 0th or X dimension to y - The scaler to set the 1st or Y dimension to

◆ Vector() [5/14]

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims>
Vector ( const t_type & x,
const t_type & y,
const typename std::enable_if< tdims==3, const t_type & >::type z )
inlineconstexpr

Sets values in each dimension to the respective value in the passed in scaler. Note the Vector must be 3 dimensions to use this function.

Author: Tyler Parke

Date: 2017-09-13

Parameters: x - The scaler to set the 0th or X dimension to y - The scaler to set the 1st or Y dimension to z - The scaler to set the 2nd or Z dimension to

◆ Vector() [6/14]

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims>
Vector ( const t_type & x,
const t_type & y,
const t_type & z,
typename std::enable_if< tdims==4, const t_type & >::type w )
inlineconstexpr

Sets values in each dimension to the respective value in the passed in scaler. Note the Vector must be 4 dimensions to use this function.

Author: Tyler Parke

Date: 2017-09-13

Parameters: x - The scaler to set the 0th or X dimension to y - The scaler to set the 1st or Y dimension to z - The scaler to set the 2nd or Z dimension to w - The scaler to set the 3rd or W dimension to

◆ Vector() [7/14]

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims>
Vector ( const t_type & x,
const t_type & y,
const t_type & z,
const t_type & w,
typename std::enable_if< tdims==5, const t_type & >::type v )
inlineconstexpr

◆ Vector() [8/14]

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims>
Vector ( const t_type & x,
const t_type & y,
const t_type & z,
const t_type & w,
const t_type & v,
typename std::enable_if< tdims==6, const t_type & >::type u )
inlineconstexpr

◆ Vector() [9/14]

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims>
Vector ( const t_type & x,
const t_type & y,
const t_type & z,
const t_type & w,
const t_type & v,
const t_type & u,
const t_type & t,
const t_type & s,
typename std::enable_if< tdims==9, const t_type & >::type r )
inlineconstexpr

◆ Vector() [10/14]

template<uint01 t_dims, class t_type >
Vector ( const t_type(&) vector[t_dims])
inlineexplicitconstexpr

Given a container of statically determined array, transforms it to a vector

Author: Tyler Parke

Date: 2017-11-13

Parameters: vector - The vector container object.

◆ Vector() [11/14]

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims>
Vector ( const Vector< tdims - 1, t_type > & vector,
typename std::enable_if< tdims > = 2,
const t_type & ,
::type suffix )
inlineconstexpr

Vectors. Creates a vector where the prefix vector is combined with the suffix scalers.

Author: Tyler Parke

Date: 2017-11-13

Parameters: vector - The vector. postfix - The postfix.

◆ Vector() [12/14]

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims>
Vector ( const Vector< getMax(tdims - 2, 0), t_type > & vector,
const t_type & suffix_a,
typename std::enable_if< tdims > = 3,
const t_type & ,
::type suffix_b )
inlineconstexpr

Vectors. Creates a vector where the prefix vector is combined with the suffix scalers.

Author: Tyler Parke

Date: 2017-11-13

Parameters: vector - The vector. postfix_a - The postfix a. postfix_b - The postfix b.

◆ Vector() [13/14]

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims>
Vector ( const t_type & prefix,
typename std::enable_if< tdims > = 2,
const Vector< t_dims - 1, t_type > & ,
::type vector )
inlineconstexpr

Vectors. Creates a vector where the prefix scaler is combined with the suffix vector.

Author: Tyler Parke

Date: 2017-11-13

Parameters: prefix - The prefix. vector - The vector.

◆ Vector() [14/14]

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims>
Vector ( const t_type & prefix_a,
const t_type & prefix_b,
typename std::enable_if< tdims > = 3,
const Vector< tdims - 1, t_type > & ,
::type vector )
inlineconstexpr

Vectors. Creates a vector where the prefix scaler values are combined with the suffix vector.

Author: Tyler Parke

Date: 2017-11-13

Parameters: prefix_a - The first prefix. prefix_b - The second prefix. vector - The vector.

Member Function Documentation

◆ as() [1/3]

template<uint01 t_dims, class t_type >
template<class t_new_type >
Vector< t_dims, t_new_type > as ( ) const
inlineconstexpr

As the given extra fill value.

Author: Tyler Parke

Date: 2017-11-13

Parameters: extra_fill_value - (Optional) The extra fill value, or value to set dimensions extra that may be created when t_new_dim > t_dim.

Returns
A Vector<t_new_dim,t_new_type>

◆ as() [2/3]

template<uint01 t_dims, class t_type >
template<uint01 t_new_dim, class t_new_type >
Vector< t_new_dim, t_new_type > as ( ) const
inlineconstexpr

◆ as() [3/3]

template<uint01 t_dims, class t_type >
template<uint01 t_new_dim, class t_new_type >
Vector< t_new_dim, t_new_type > as ( t_new_type extra_fill_value) const
inlineconstexpr

◆ dimensionalIndex()

template<uint01 t_dims, class t_type >
template<LocationValues t_max_min>
uint01 dimensionalIndex ( ) const
inlinenodiscardconstexpr

Used with template arguments MAX or MIN, Gets the dimensional index for the value that is either max or min.

Author: Tyler Parke

Date: 2017-11-13

Returns
The index of the dimension that is either max or min depending on the template t_max_min.

◆ dimensionalValue()

template<uint01 t_dims, class t_type >
template<LocationValues t_max_min>
t_type dimensionalValue ( ) const
inlinenodiscardconstexpr

Used with template arguments MAX or MIN, Gets the dimensional value for the value that is either max or min.

Author: Tyler Parke

Date: 2017-11-13

Returns
The value of the dimension that is either max or min depending on the template t_max_min.

◆ magnitude()

template<uint01 t_dims, class t_type >
template<class t_magnitude_type = t_type>
t_magnitude_type magnitude ( ) const
inlineconstexpr

Vectors are commonly used to model forces such as wind, sea current, gravity, and electromagnetism. Calculating the magnitude of vectors is essential for all sorts of problems where forces collide.

Magnitude is defined as the length of a vector. The notation for absolute value. Thus magnitude is the same as length of vector.

Author: Tyler Parke

Date: 2017-11-13

Returns
The magnitude, or length, of the vector.

◆ magnitudeSquared()

template<uint01 t_dims, class t_type >
t_type magnitudeSquared ( ) const
inlinenodiscardconstexpr

Vectors are commonly used to model forces such as wind, sea current, gravity, and electromagnetism. Calculating the magnitude of vectors is essential for all sorts of problems where forces collide.

Magnitude is defined as the length of a vector. The notation for absolute value. Thus magnitude is the same as length of vector.

Author: Tyler Parke

Date: 2017-11-13

Returns
The magnitude, or length, of the vector squared.

◆ normalized()

template<uint01 t_dims, class t_type >
template<class t_norm_type = t_type>
Vector< t_dims, t_norm_type > normalized ( Vector< t_dims, t_norm_type > value_if_nan = Constant<Vector<t_dims, t_norm_type>>::Invalid) const
inlineconstexpr

Gets the normalized, or unit length representation of this vector.

Author: Tyler Parke

Date: 2017-11-13

Returns
A Vector<t_dims,t_norm_type&gt representing the normalized form of this vector;

◆ NumberOfDimensions()

template<uint01 t_dims, class t_type >
static constexpr uint01 NumberOfDimensions ( )
inlinestaticconstexpr

Number of dimensions in this vector class.

Author: Tyler Parke

Date: 2017-11-13

Returns
The total number of dimensions in this vector space.

◆ operator const t_type &()

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims, typename = typename std::enable_if<tdims == 1>::type>
operator const t_type & ( ) const
inlineconstexpr

◆ operator t_type &()

template<uint01 t_dims, class t_type >
template<uint01 tdims = t_dims, typename = typename std::enable_if<tdims == 1>::type>
operator t_type & ( )
inlineconstexpr

For Single dimensional objects, they may also be considered a scaler, thus allow implicit conversion from a vector to a scaler when the dimension of the vector is 1.

Author: Tyler Parke

Date: 2017-11-13

Returns
The result of the operation.

◆ operator-()

template<uint01 t_dims, class t_type >
Vector< t_dims, t_type > operator- ( ) const
inlineconstexpr

Negation operator.

Author: Tyler Parke

Date: 2017-11-13

Returns
A vector where each dimension is the opposite(-) of the original dimension

◆ operator=()

template<uint01 t_dims, class t_type >
Vector< t_dims, t_type > & operator= ( const t_type & scaler)
inlineconstexpr

Assignment operator.

Author: Tyler Parke

Date: 2017-11-13

Parameters: vector - The vector to set this vector to.

Returns
A reference of this object (Useful for chaining '=' together).
Assignment operator. Sets all values to the value provided in scaler argument.

Author: Tyler Parke

Date: 2017-11-13

Parameters: scaler - The scaler to set each dimension to.

Returns
A reference of this object (Useful for chaining '=' together).

◆ operator[]() [1/2]

template<uint01 t_dims, class t_type >
const t_type & operator[] ( const uint01 dimension_index) const
inlineconstexpr

◆ operator[]() [2/2]

template<uint01 t_dims, class t_type >
t_type & operator[] ( uint01 dimension_index)
inlineconstexpr

Accesses the value of a certain dimension.

Author: Tyler Parke

Date: 2017-11-13

Parameters: dimension_index - The dimensional index of the the value we wish to retrieve.

Returns
The value at the given dimension_index.

◆ product()

template<uint01 t_dims, class t_type >
t_type product ( ) const
inlinenodiscardconstexpr

Returns the product, or value of each dimension multiplied together.

Author: Tyler Parke

Date: 2017-11-13

Returns
The value of each dimension multiplied together.

◆ sum()

template<uint01 t_dims, class t_type >
t_type sum ( ) const
inlinenodiscardconstexpr

Returns the sum, or value of each dimension added together.

Author: Tyler Parke

Date: 2017-11-13

Returns
The value of each dimension added together.

◆ Type()

template<uint01 t_dims, class t_type >
static constexpr t_type Type ( )
inlinestaticconstexpr

Returns the type of this class. Useful for using decltype to instantiate a member of this class in a static environment.

Author: Tyler Parke

Date: 2017-11-13

Returns
The type of this class. Object is inavlid outside of decl.

Member Data Documentation

◆ m_values

template<uint01 t_dims, class t_type >
t_type m_values[t_dims]
protected

The values[t dims].


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