update
This commit is contained in:
@@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
#include "mini-odeint.hpp"
|
#include "mini-odeint.hpp"
|
||||||
|
|
||||||
#include <ranges>
|
|
||||||
|
|
||||||
unsigned int Factorial(unsigned int number) {
|
unsigned int Factorial(unsigned int number) {
|
||||||
return number <= 1 ? number : Factorial(number - 1) * number;
|
return number <= 1 ? number : Factorial(number - 1) * number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,29 +158,47 @@ template <typename E> struct Vec2 {
|
|||||||
E x, y;
|
E x, y;
|
||||||
|
|
||||||
constexpr Vec2() = default;
|
constexpr Vec2() = default;
|
||||||
constexpr Vec2(E x, E y) : x(x), y(y) {}
|
constexpr Vec2(E x, E y) : x(std::move(x)), y(std::move(y)) {}
|
||||||
|
|
||||||
constexpr explicit Vec2(std::array<E, 3> v) : x(v[0]), y(v[1]) {}
|
constexpr explicit Vec2(std::array<E, 3> v) : x(v[0]), y(v[1]) {}
|
||||||
|
|
||||||
friend constexpr Vec2 operator+(Vec2 lhs, const Vec2 &rhs) {
|
friend constexpr Vec2 operator+(Vec2 lhs, const Vec2 &rhs) {
|
||||||
return lhs += rhs;
|
return lhs += rhs;
|
||||||
}
|
}
|
||||||
|
friend constexpr Vec2 operator-(Vec2 lhs, const Vec2 &rhs) {
|
||||||
|
return lhs -= rhs;
|
||||||
|
}
|
||||||
friend constexpr Vec2 operator*(Vec2 lhs, const value_type &rhs) {
|
friend constexpr Vec2 operator*(Vec2 lhs, const value_type &rhs) {
|
||||||
return lhs *= rhs;
|
return lhs *= rhs;
|
||||||
}
|
}
|
||||||
friend constexpr Vec2 operator*(const value_type &lhs, Vec2 rhs) {
|
friend constexpr Vec2 operator*(const value_type &lhs, Vec2 rhs) {
|
||||||
return rhs *= lhs;
|
return rhs *= lhs;
|
||||||
}
|
}
|
||||||
|
friend constexpr Vec2 operator/(Vec2 lhs, const value_type &rhs) {
|
||||||
|
return lhs /= rhs;
|
||||||
|
}
|
||||||
|
constexpr Vec2 operator-() const { return Vec2{-x, -y}; }
|
||||||
|
|
||||||
constexpr Vec2 &operator+=(const Vec2 &rhs) {
|
constexpr Vec2 &operator+=(const Vec2 &rhs) {
|
||||||
x += rhs.x;
|
x += rhs.x;
|
||||||
y += rhs.y;
|
y += rhs.y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
constexpr Vec2 &operator-=(const Vec2 &rhs) {
|
||||||
|
x -= rhs.x;
|
||||||
|
y -= rhs.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
constexpr Vec2 &operator*=(const value_type &rhs) {
|
constexpr Vec2 &operator*=(const value_type &rhs) {
|
||||||
x *= rhs;
|
x *= rhs;
|
||||||
y *= rhs;
|
y *= rhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
constexpr Vec2 &operator/=(const value_type &rhs) {
|
||||||
|
x /= rhs;
|
||||||
|
y /= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename E> struct Vec3 {
|
template <typename E> struct Vec3 {
|
||||||
@@ -189,31 +207,56 @@ template <typename E> struct Vec3 {
|
|||||||
E x, y, z;
|
E x, y, z;
|
||||||
|
|
||||||
constexpr Vec3() = default;
|
constexpr Vec3() = default;
|
||||||
constexpr Vec3(E x, E y, E z) : x(x), y(y), z(z) {}
|
constexpr Vec3(E x, E y, E z)
|
||||||
|
: x(std::move(x)), y(std::move(y)), z(std::move(z)) {}
|
||||||
|
|
||||||
constexpr explicit Vec3(std::array<E, 3> v) : x(v[0]), y(v[1]), z(v[2]) {}
|
explicit constexpr Vec3(const std::array<E, 3> &v)
|
||||||
|
: x(v[0]), y(v[1]), z(v[2]) {}
|
||||||
|
|
||||||
|
explicit constexpr Vec3(std::span<const E, 3> v)
|
||||||
|
: x(v[0]), y(v[1]), z(v[2]) {}
|
||||||
|
|
||||||
friend constexpr Vec3 operator+(Vec3 lhs, const Vec3 &rhs) {
|
friend constexpr Vec3 operator+(Vec3 lhs, const Vec3 &rhs) {
|
||||||
return lhs += rhs;
|
return lhs += rhs;
|
||||||
}
|
}
|
||||||
|
friend constexpr Vec3 operator-(Vec3 lhs, const Vec3 &rhs) {
|
||||||
|
return lhs -= rhs;
|
||||||
|
}
|
||||||
friend constexpr Vec3 operator*(Vec3 lhs, const value_type &rhs) {
|
friend constexpr Vec3 operator*(Vec3 lhs, const value_type &rhs) {
|
||||||
return lhs *= rhs;
|
return lhs *= rhs;
|
||||||
}
|
}
|
||||||
friend constexpr Vec3 operator*(const value_type &lhs, Vec3 rhs) {
|
friend constexpr Vec3 operator*(const value_type &lhs, Vec3 rhs) {
|
||||||
return rhs *= lhs;
|
return rhs *= lhs;
|
||||||
}
|
}
|
||||||
|
friend constexpr Vec3 operator/(Vec3 lhs, const value_type &rhs) {
|
||||||
|
return lhs /= rhs;
|
||||||
|
}
|
||||||
|
constexpr Vec3 operator-() const { return Vec3{-x, -y, -z}; }
|
||||||
|
|
||||||
constexpr Vec3 &operator+=(const Vec3 &rhs) {
|
constexpr Vec3 &operator+=(const Vec3 &rhs) {
|
||||||
x += rhs.x;
|
x += rhs.x;
|
||||||
y += rhs.y;
|
y += rhs.y;
|
||||||
z += rhs.z;
|
z += rhs.z;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
constexpr Vec3 &operator-=(const Vec3 &rhs) {
|
||||||
|
x -= rhs.x;
|
||||||
|
y -= rhs.y;
|
||||||
|
z -= rhs.z;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
constexpr Vec3 &operator*=(const value_type &rhs) {
|
constexpr Vec3 &operator*=(const value_type &rhs) {
|
||||||
x *= rhs;
|
x *= rhs;
|
||||||
y *= rhs;
|
y *= rhs;
|
||||||
z *= rhs;
|
z *= rhs;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
constexpr Vec3 &operator/=(const value_type &rhs) {
|
||||||
|
x /= rhs;
|
||||||
|
y /= rhs;
|
||||||
|
z /= rhs;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace func {
|
namespace func {
|
||||||
|
|||||||
Reference in New Issue
Block a user