mirror of
https://github.com/slendidev/smath.git
synced 2026-01-30 16:58:58 +02:00
@@ -188,9 +188,12 @@ public:
|
|||||||
// NOTE: This can (probably) be improved with C++26 reflection in the
|
// NOTE: This can (probably) be improved with C++26 reflection in the
|
||||||
// future.
|
// future.
|
||||||
#define VEC_ACC(component, req, idx) \
|
#define VEC_ACC(component, req, idx) \
|
||||||
constexpr auto component() noexcept -> T &requires(N >= req) { \
|
constexpr auto component() noexcept -> T & \
|
||||||
|
requires(N >= req) \
|
||||||
|
{ \
|
||||||
return (*this)[idx]; \
|
return (*this)[idx]; \
|
||||||
} constexpr auto component() const->T const & \
|
} \
|
||||||
|
constexpr auto component() const -> T const & \
|
||||||
requires(N >= req) \
|
requires(N >= req) \
|
||||||
{ \
|
{ \
|
||||||
return (*this)[idx]; \
|
return (*this)[idx]; \
|
||||||
@@ -281,13 +284,13 @@ public:
|
|||||||
VEC_OP(/)
|
VEC_OP(/)
|
||||||
#undef VEC_OP
|
#undef VEC_OP
|
||||||
#define VEC_OP_ASSIGN(sym) \
|
#define VEC_OP_ASSIGN(sym) \
|
||||||
constexpr Vec &operator sym##=(Vec const &rhs) noexcept \
|
constexpr Vec &operator sym## = (Vec const &rhs) noexcept \
|
||||||
{ \
|
{ \
|
||||||
for (std::size_t i = 0; i < N; ++i) \
|
for (std::size_t i = 0; i < N; ++i) \
|
||||||
(*this)[i] sym## = rhs[i]; \
|
(*this)[i] sym## = rhs[i]; \
|
||||||
return *this; \
|
return *this; \
|
||||||
} \
|
} \
|
||||||
constexpr Vec &operator sym##=(T const &s) noexcept \
|
constexpr Vec &operator sym## = (T const &s) noexcept \
|
||||||
{ \
|
{ \
|
||||||
for (std::size_t i = 0; i < N; ++i) \
|
for (std::size_t i = 0; i < N; ++i) \
|
||||||
(*this)[i] sym## = s; \
|
(*this)[i] sym## = s; \
|
||||||
@@ -421,8 +424,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class U>
|
template<class U>
|
||||||
requires(std::is_arithmetic_v<U> && N >= 1) constexpr explicit(
|
requires(std::is_arithmetic_v<U> && N >= 1)
|
||||||
!std::is_convertible_v<T, U>) operator Vec<N, U>() const noexcept
|
constexpr explicit(!std::is_convertible_v<T, U>)
|
||||||
|
operator Vec<N, U>() const noexcept
|
||||||
{
|
{
|
||||||
Vec<N, U> r {};
|
Vec<N, U> r {};
|
||||||
for (std::size_t i = 0; i < N; ++i)
|
for (std::size_t i = 0; i < N; ++i)
|
||||||
@@ -446,9 +450,8 @@ private:
|
|||||||
}
|
}
|
||||||
#ifdef SMATH_IMPLICIT_CONVERSIONS
|
#ifdef SMATH_IMPLICIT_CONVERSIONS
|
||||||
template<class U>
|
template<class U>
|
||||||
requires std::is_arithmetic_v<U>
|
requires std::is_arithmetic_v<U> && (!std::is_same_v<U, T>)constexpr void
|
||||||
&& (!std::is_same_v<U, T>)constexpr void fill_one(
|
fill_one(std::size_t &i, const U &v) noexcept
|
||||||
std::size_t &i, const U &v) noexcept
|
|
||||||
{
|
{
|
||||||
(*this)[i++] = static_cast<T>(v);
|
(*this)[i++] = static_cast<T>(v);
|
||||||
}
|
}
|
||||||
@@ -1115,9 +1118,9 @@ template<typename T>
|
|||||||
auto u = s.cross(f);
|
auto u = s.cross(f);
|
||||||
|
|
||||||
return Mat<4, 4, T> {
|
return Mat<4, 4, T> {
|
||||||
Vec<4, T> { s.x(), s.y(), s.z(), 0 },
|
Vec<4, T> { s.x(), u.x(), -f.x(), 0 },
|
||||||
Vec<4, T> { u.x(), u.y(), u.z(), 0 },
|
Vec<4, T> { s.y(), u.y(), -f.y(), 0 },
|
||||||
Vec<4, T> { -f.x(), -f.y(), -f.z(), 0 },
|
Vec<4, T> { s.z(), u.z(), -f.z(), 0 },
|
||||||
Vec<4, T> { -s.dot(eye), -u.dot(eye), f.dot(eye), 1 },
|
Vec<4, T> { -s.dot(eye), -u.dot(eye), f.dot(eye), 1 },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user