SImplify acceleration addition. #1

Merged
tfaour merged 5 commits from tfaour-patch-1 into main 2025-06-02 21:29:55 -04:00
Showing only changes of commit 7dd2b88b8a - Show all commits

View File

@ -1,13 +1,20 @@
#include "body.hpp" #include "body.hpp"
#include "calc.hpp" #include "calc.hpp"
#include <cmath> #include <cmath>
#include <boost/multiprecision/cpp_dec_float.hpp> #include <ranges>
Body::Body(const Position& X, const Velocity& V, const Mass& m, const std::string& name) Body::Body(const Position& X, const Velocity& V, const Mass& m, const std::string& name)
: X(X), V(V), m(m), name(name) { : X(X), V(V), m(m), name(name) {
A = Acceleration{Decimal(0), Decimal(0), Decimal(0)}; A = Acceleration{Decimal(0), Decimal(0), Decimal(0)};
} }
void addAcceleration(const Acceleration& new_A) {
for (auto& [new_a, cur_a]: std::views::zip(new_A, this->A)){
cur_a += new_a;
}
}
std::tuple<Position, Velocity, Mass> Body::save() const { std::tuple<Position, Velocity, Mass> Body::save() const {
return std::make_tuple(X, V, m); return std::make_tuple(X, V, m);
} }