bissl Fortschritt, ich will aber erst Aufg 3 machen

This commit is contained in:
Tobias Kachel 2026-04-23 15:07:56 +02:00
parent be77aebb25
commit 3b1a8af39d
2 changed files with 53 additions and 41 deletions

View File

@ -1,45 +1,38 @@
#include "flugkurve02.h"
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main() Vektor mulVektor(const Vektor &vec, const float &skalar){
{ Vektor ergebnis = {vec.x * num, vec.y * num};
// Körper: return ergebnis;
float masse = 10; // [kg] }
float xPosition = 0; // [m]
float yPosition = 0; // [m] Vektor addVektor(Vektor vec1, Vektor vec2) {
float xGeschwindigkeit = 10; // [m/s] Vektor erg = {vec1.x + vec2.x, vec1.y + vec2.y};
float yGeschwindigkeit = 10; // [m/s] return erg;
}
// Parametrierung der auf den Körper wirkende Kräfte:
const float X_BESCHLEUNIGUNG_GRAVITATION = 0; // [m/s^2] Koerper bewegeKoerper(Koerper korp, Vektor gesamtkraft, float dt) {
const float Y_BESCHLEUNIGUNG_GRAVITATION = -9.81; // [m/s^2]
const float REIBUNGSKOEFFIZIENT = -5; // [kg/s] // Berechnung der Beschleunigung aus der Kraft
float xBeschleunigung = gesamtkraft.x / korp.masse;
// Sorgt dafür, dass 2 Nachkommastellen angezeigt werden: float yBeschleunigung = gesamtkraft.y / korp.masse;
cout << fixed;
cout.precision(2); // Ermittlung der neuen Geschwindigkeit
korp.geschwindigkeit.x += dt * xBeschleunigung;
// Simulation: korp.geschwindigkeit.y += dt * yBeschleunigung;
const float dt = 0.1; // [s]
for(;;) // Ermittlung der neuen Position
{ korp.position.x += dt * korp.geschwindigkeit.x;
cout << "(" << xPosition << "," << yPosition << ")" << endl; korp.position.y += dt * korp.geschwindigkeit.y;
return korp;
// Berechnung der Beschleunigung aus der Kraft }
float xBeschleunigung = xGeschwindigkeit * REIBUNGSKOEFFIZIENT / masse + X_BESCHLEUNIGUNG_GRAVITATION;
float yBeschleunigung = yGeschwindigkeit * REIBUNGSKOEFFIZIENT / masse + Y_BESCHLEUNIGUNG_GRAVITATION; void ausgabeKoerper(Koerper korp){
cout << "x = " << korp.position.x << "y = " << korp.position.y;
// Ermittlung der neuen Geschwindigkeit }
xGeschwindigkeit += dt * xBeschleunigung;
yGeschwindigkeit += dt * yBeschleunigung; void ausgabeVektor(Vektor vec){
cout << "x = " << vec.x << endl;
// Ermittlung der neuen Position cout << "y = " << vec.y << endl;
xPosition += dt * xGeschwindigkeit;
yPosition += dt * yGeschwindigkeit;
if(yPosition<=0)
{
break;
}
}
} }

View File

@ -0,0 +1,19 @@
#pragma once
// Parametrierung der auf den Körper wirkende Kräfte:
struct Vektor {
const float x; // [m/s^2]
const float y; // [m/s^2]
};
// Körper:
struct Koerper {
float masse; // [kg]
Vektor position;
Vektor geschwindigkeit;
};
Vektor addVektor(Vektor vec1, Vektor vec2);
Vektor mulVektor(Vektor vec, float skalar);
Koerper bewegeKoerper(Koerper korp, Vektor gesamtkraft, float dt);
void ausgabeKoerper(Koerper korp);
void ausgabeVektor(Vektor vec);