13 using namespace gravitation;
21 output << std::setprecision(3);
24 const double z0 = 0.0, v0 = 20.0;
25 const double g = Earth::g;
28 double t = 0, dt = 1e-3, z = z0, v = v0;
32 z = z0 + v0 * t - 0.5 * g * pow(t, 2);
37 auto itr = std::adjacent_find(
ALL(table.
data()),
38 [](
const auto &x,
const auto &y) {
39 return x[2] * y[2] < 0;
43 View view = table.
view({ itr, itr + 1 },
false,
true);
46 output << std::setprecision(3);
47 output << std::setw(5) <<
"t" << std::setw(10) <<
"z" << std::setw(10) <<
"v" << std::endl;
48 output <<
"-------------------------------" << std::endl;
50 output <<
"-------------------------------" << std::endl;
52 Data::Row r1{ v0 / Earth::g, 0.5 * pow(v0, 2) / Earth::g, 0 };
53 Data::Row r2{ 2 * v0 / Earth::g, 0, -v0 };
61 const double mass = 2.0;
62 const double force = 10.0;
64 const double t = 10.0;
66 for (
double phi : { 10, 30, 45, 60 }) {
69 const double fx = force * cos(phirad);
70 const double fy = force * sin(phirad);
71 const double ax = fx / mass;
72 const double vx = ax * t;
73 const double x = 0.5 * ax * pow(t, 2);
74 const double work = fx * x;
76 table += { phi, fx, fy, ax, vx, x, work };
91 const double m = 200.0_g;
94 for (
auto M : { 1.0, 5.0, 10.0 }) {
95 const double factor = m / (m + M);
96 for (
auto v : { 200.0, 400.0, 600.0 }) {
97 const auto vp = factor * v;
99 const auto ekinB = 0.5 * m * pow(v, 2);
101 const auto ekinA = 0.5 * (M + m) * pow(vp, 2);
102 const auto ekinDiff = 100 * abs(ekinA - ekinB) / ekinB;
104 table += { M, v, vp, ekinB, ekinA, ekinDiff };
116 using namespace gravitation;
119 const auto xmin = Earth::radius;
120 const auto xmax = 2 * xmin;
122 const auto dx = 1000.0_km;
123 const auto mass = 10.0;
124 const auto factor = Astronomy::G * Earth::mass * mass;
126 for (
double x = xmin; x < xmax; x += dx) {
127 const auto force = -factor / pow(x + xmin, 2);
128 const auto pEnergy = -factor / (x + xmin);
130 table += { x, force, pEnergy };
147 data += { 3, 2, 3.46 };
150 std::array cmPosition{ 0.0, 0.0 };
154 auto calcCM = [&cmMass, &cmPosition](
const Data::Row &row) {
156 cmPosition[0] += row[0] * row[1];
157 cmPosition[1] += row[0] * row[2];
162 cmPosition[0] /= cmMass;
163 cmPosition[1] /= cmMass;
166 data += { cmMass, cmPosition[0], cmPosition[1] };
void apply(FN fn)
apply ändere alle oder bestimmte Elemente
auto view() const
view die ganze Tabelle als view
void save(std::ostream &ofs, Format fmt) const
save Schreibe Tabelle in Datei
The Data class Eine Klasse für Zahlentabellen mit fester Anzahl von Spalten. Die Anzahl der Reihen wä...
void ex26()
ex26 Kraft und potenzielle Energie im Gravitationsfeld der Erde
const auto & data() const
data lesender Zugriff auf die interne Struktur
static std::ofstream get_stream(const std::string &fname)
get_output_stream Öffnen einer Ausgabedatei falls die Datei nicht geöffnet werden kann wird ein Fehle...
static double to_radians(double x)
void ex27()
ex27 Massenschwerpunkt von drei Teilchen
The View class Sicht auf Teilmenge eines Containers.
void ex23()
ex23 Teilchen wird vertikal nach oben geworfen
static const Format latex
void ex24()
ex24 Kraft beschleunigt eine Masse auf reibungsfreien Boden
std::array< double, N > Row
void ex25()
ex25 Geschoss trifft auf ruhenden Holzblock