sandbox
Loading...
Searching...
No Matches
vector.hpp File Reference

Generic fixed-size vector type. More...

#include <algorithm>
#include <array>
#include <cmath>
#include <concepts>
#include <ranges>
#include <utility>
#include <libsbx/utility/make_array.hpp>
#include <libsbx/utility/assert.hpp>
#include <libsbx/utility/zip.hpp>
#include <libsbx/utility/hash.hpp>
#include <libsbx/math/concepts.hpp>
#include <libsbx/math/traits.hpp>
#include <libsbx/math/constants.hpp>
#include <libsbx/math/algorithm.hpp>
#include <libsbx/math/vector.ipp>

Go to the source code of this file.

Classes

class  sbx::math::basic_vector< Size, Type >
 Fixed-size vector type. More...
 

Namespaces

namespace  libsbx
 

Functions

template<std::size_t Size, scalar Lhs, scalar Rhs>
constexpr auto sbx::math::operator== (const basic_vector< Size, Lhs > &lhs, const basic_vector< Size, Rhs > &rhs) noexcept -> bool
 Equality comparison for vectors. More...
 
template<std::size_t Size, scalar Lhs, scalar Rhs>
constexpr auto sbx::math::operator+ (basic_vector< Size, Lhs > lhs, const basic_vector< Size, Rhs > &rhs) noexcept -> basic_vector< Size, Lhs >
 Vector addition. More...
 
template<std::size_t Size, scalar Lhs, scalar Rhs>
constexpr auto sbx::math::operator- (basic_vector< Size, Lhs > lhs, const basic_vector< Size, Rhs > &rhs) noexcept -> basic_vector< Size, Lhs >
 Vector subtraction. More...
 
template<std::size_t Size, scalar Lhs, scalar Rhs>
constexpr auto sbx::math::operator* (basic_vector< Size, Lhs > lhs, Rhs scalar) noexcept -> basic_vector< Size, Lhs >
 Scalar multiplication. More...
 
template<std::size_t Size, scalar Lhs, scalar Rhs>
constexpr auto sbx::math::operator/ (basic_vector< Size, Lhs > lhs, Rhs scalar) noexcept -> basic_vector< Size, Lhs >
 Scalar division. More...
 

Detailed Description

Generic fixed-size vector type.

This header defines a statically sized vector template parameterized by component count and scalar type.

The vector stores its components contiguously and supports basic arithmetic, interpolation, normalization, and utility operations such as component-wise min/max and absolute value.

Author
KAJ

Function Documentation

◆ operator*()

template<std::size_t Size, scalar Lhs, scalar Rhs>
constexpr auto sbx::math::operator* ( basic_vector< Size, Lhs >  lhs,
Rhs  scalar 
) -> basic_vector<Size, Lhs>
constexprnoexcept

Scalar multiplication.

Template Parameters
SizeComponent count.
LhsLeft-hand scalar type.
RhsRight-hand scalar type.
Parameters
lhsLeft-hand side vector.
scalarScalar multiplier.
Returns
Scaled vector.

◆ operator+()

template<std::size_t Size, scalar Lhs, scalar Rhs>
constexpr auto sbx::math::operator+ ( basic_vector< Size, Lhs >  lhs,
const basic_vector< Size, Rhs > &  rhs 
) -> basic_vector<Size, Lhs>
constexprnoexcept

Vector addition.

Template Parameters
SizeComponent count.
LhsLeft-hand scalar type.
RhsRight-hand scalar type.
Parameters
lhsLeft-hand side vector.
rhsRight-hand side vector.
Returns
Sum of both vectors.

◆ operator-()

template<std::size_t Size, scalar Lhs, scalar Rhs>
constexpr auto sbx::math::operator- ( basic_vector< Size, Lhs >  lhs,
const basic_vector< Size, Rhs > &  rhs 
) -> basic_vector<Size, Lhs>
constexprnoexcept

Vector subtraction.

Template Parameters
SizeComponent count.
LhsLeft-hand scalar type.
RhsRight-hand scalar type.
Parameters
lhsLeft-hand side vector.
rhsRight-hand side vector.
Returns
Difference of both vectors.

◆ operator/()

template<std::size_t Size, scalar Lhs, scalar Rhs>
constexpr auto sbx::math::operator/ ( basic_vector< Size, Lhs >  lhs,
Rhs  scalar 
) -> basic_vector<Size, Lhs>
constexprnoexcept

Scalar division.

Template Parameters
SizeComponent count.
LhsLeft-hand scalar type.
RhsRight-hand scalar type.
Parameters
lhsLeft-hand side vector.
scalarScalar divisor.
Returns
Scaled vector.

◆ operator==()

template<std::size_t Size, scalar Lhs, scalar Rhs>
constexpr auto sbx::math::operator== ( const basic_vector< Size, Lhs > &  lhs,
const basic_vector< Size, Rhs > &  rhs 
) -> bool
constexprnoexcept

Equality comparison for vectors.

Template Parameters
SizeComponent count.
LhsLeft-hand scalar type.
RhsRight-hand scalar type.
Parameters
lhsLeft-hand side vector.
rhsRight-hand side vector.
Returns
True if all components are equal.