LeviLamina
Loading...
Searching...
No Matches
IntN.h
1#pragma once
2
3#include <cstddef>
4
5#include "ll/api/base/Macro.h"
6
7#include "mc/math/vector/base/Field.h"
8#include "mc/math/vector/base/VectorBase.h"
9
10namespace ll::math {
11template <size_t N>
12class doubleN;
13
14template <typename T, typename... Components>
15class LL_EBO IntN : public Field<T, Components...>, public IntNTag {
16public:
17 using first_type = Field<T, Components...>::first_type;
18
19 [[nodiscard]] constexpr T cross(T const& b) const noexcept
20 requires(IntN::size() == 3)
21 {
22 return {
23 static_cast<T const*>(this)->template get<first_type, 1>() * b.template get<first_type, 2>()
24 - static_cast<T const*>(this)->template get<first_type, 2>() * b.template get<first_type, 1>(),
25 static_cast<T const*>(this)->template get<first_type, 2>() * b.template get<first_type, 0>()
26 - static_cast<T const*>(this)->template get<first_type, 0>() * b.template get<first_type, 2>(),
27 static_cast<T const*>(this)->template get<first_type, 0>() * b.template get<first_type, 1>()
28 - static_cast<T const*>(this)->template get<first_type, 1>() * b.template get<first_type, 0>()
29 };
30 }
31};
32
33#define LL_VEC_GEN_BASIC_MATH_FUNC_INT(NAME) \
34 template <IsIntN T> \
35 [[nodiscard]] constexpr doubleN<T::size()> NAME(T const& x) noexcept \
36 requires(T::size() >= 2 && T::size() <= 4) \
37 { \
38 doubleN<T::size()> tmp; \
39 T::forEachComponent([&]<typename axis_type, size_t iter> { \
40 tmp.template get<double, iter>() = static_cast<double>(std::NAME(x.template get<axis_type, iter>())); \
41 }); \
42 return tmp; \
43 }
44
45LL_VEC_GEN_BASIC_MATH_FUNC_INT(acos)
46LL_VEC_GEN_BASIC_MATH_FUNC_INT(asin)
47LL_VEC_GEN_BASIC_MATH_FUNC_INT(atan)
48LL_VEC_GEN_BASIC_MATH_FUNC_INT(acosh)
49LL_VEC_GEN_BASIC_MATH_FUNC_INT(asinh)
50LL_VEC_GEN_BASIC_MATH_FUNC_INT(atanh)
51LL_VEC_GEN_BASIC_MATH_FUNC_INT(ceil)
52LL_VEC_GEN_BASIC_MATH_FUNC_INT(cos)
53LL_VEC_GEN_BASIC_MATH_FUNC_INT(cosh)
54LL_VEC_GEN_BASIC_MATH_FUNC_INT(exp)
55LL_VEC_GEN_BASIC_MATH_FUNC_INT(fabs)
56LL_VEC_GEN_BASIC_MATH_FUNC_INT(floor)
57LL_VEC_GEN_BASIC_MATH_FUNC_INT(log)
58LL_VEC_GEN_BASIC_MATH_FUNC_INT(log2)
59LL_VEC_GEN_BASIC_MATH_FUNC_INT(log10)
60LL_VEC_GEN_BASIC_MATH_FUNC_INT(round)
61LL_VEC_GEN_BASIC_MATH_FUNC_INT(sin)
62LL_VEC_GEN_BASIC_MATH_FUNC_INT(sinh)
63LL_VEC_GEN_BASIC_MATH_FUNC_INT(sqrt)
64LL_VEC_GEN_BASIC_MATH_FUNC_INT(tan)
65LL_VEC_GEN_BASIC_MATH_FUNC_INT(tanh)
66
67// LL_VEC_GEN_BASIC_MATH_FUNC_INT(atan2)
68// LL_VEC_GEN_BASIC_MATH_FUNC_INT(modf)
69// LL_VEC_GEN_BASIC_MATH_FUNC_INT(fmod)
70// LL_VEC_GEN_BASIC_MATH_FUNC_INT(pow)
71} // namespace ll::math
Definition IntN.h:15
Definition Field.h:19
Definition VectorBase.h:37