5#include "ll/api/base/Macro.h"
7#include "mc/math/vector/base/Field.h"
8#include "mc/math/vector/base/VectorBase.h"
11template <
typename T,
typename... Components>
14 using first_type =
Field<T, Components...>::first_type;
16 [[nodiscard]]
constexpr T normalize()
const noexcept {
17 return *(
static_cast<T const*
>(
this)) /
static_cast<first_type
>(this->length());
20 [[nodiscard]]
constexpr double angle(T
const& b)
const noexcept {
return acos(normalize().dot(b.normalize())); }
22 [[nodiscard]]
constexpr T cross(T
const& b)
const noexcept
23 requires(FloatN::size() == 3)
26 static_cast<T const*
>(
this)->
template get<first_type, 1>() * b.template get<first_type, 2>()
27 -
static_cast<T const*
>(
this)->
template get<first_type, 2>() * b.template get<first_type, 1>(),
28 static_cast<T const*
>(
this)->
template get<first_type, 2>() * b.template get<first_type, 0>()
29 -
static_cast<T const*
>(
this)->
template get<first_type, 0>() * b.template get<first_type, 2>(),
30 static_cast<T const*
>(
this)->
template get<first_type, 0>() * b.template get<first_type, 1>()
31 -
static_cast<T const*
>(
this)->
template get<first_type, 1>() * b.template get<first_type, 0>()
37[[nodiscard]]
constexpr T lerp(T
const& a, T
const& b, T
const& x)
noexcept {
39 T::forEachComponent([&]<
typename axis_type,
size_t iter> {
40 tmp.template get<axis_type, iter>() = std::lerp(
41 a.template get<axis_type, iter>(),
42 b.template get<axis_type, iter>(),
43 x.template get<axis_type, iter>()
49LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, acos)
50LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, asin)
51LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, atan)
52LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, acosh)
53LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, asinh)
54LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, atanh)
55LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, ceil)
56LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, cos)
57LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, cosh)
58LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, exp)
59LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, fabs)
60LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, floor)
61LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, log)
62LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, log2)
63LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, log10)
64LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, round)
65LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, sin)
66LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, sinh)
67LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, sqrt)
68LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, tan)
69LL_VEC_GEN_BASIC_MATH_FUNC_FLOAT(IsFloatN, tanh)
78[[nodiscard]]
constexpr T atan2(T
const& a, T
const& b)
noexcept {
80 T::forEachComponent([&]<
typename axis_type,
size_t iter> {
81 tmp.template get<axis_type, iter>() =
82 std::atan2(a.template get<axis_type, iter>(), b.template get<axis_type, iter>());
88[[nodiscard]]
constexpr T fmod(T
const& a, T
const& b)
noexcept {
90 T::forEachComponent([&]<
typename axis_type,
size_t iter> {
91 tmp.template get<axis_type, iter>() =
92 std::fmod(a.template get<axis_type, iter>(), b.template get<axis_type, iter>());
98[[nodiscard]]
constexpr T modf(T
const& a, T
const& b)
noexcept {
100 T::forEachComponent([&]<
typename axis_type,
size_t iter> {
101 tmp.template get<axis_type, iter>() =
102 std::modf(a.template get<axis_type, iter>(), b.template get<axis_type, iter>());
108[[nodiscard]]
constexpr T pow(T
const& a, T
const& b)
noexcept {
110 T::forEachComponent([&]<
typename axis_type,
size_t iter> {
111 tmp.template get<axis_type, iter>() =
112 std::pow(a.template get<axis_type, iter>(), b.template get<axis_type, iter>());
Definition VectorBase.h:42