diff --git a/5_Flugkurve03/code/flugkurve03 b/5_Flugkurve03/code/flugkurve03 new file mode 100755 index 0000000..b6ebd01 Binary files /dev/null and b/5_Flugkurve03/code/flugkurve03 differ diff --git a/5_Flugkurve03/code/flugkurve03.cpp b/5_Flugkurve03/code/flugkurve03.cpp index df77f44..3d0d45a 100644 --- a/5_Flugkurve03/code/flugkurve03.cpp +++ b/5_Flugkurve03/code/flugkurve03.cpp @@ -15,27 +15,28 @@ void Vektor::add(const Vektor &vec2) { this->y += vec2.y; } -Koerper bewegeKoerper(const Koerper &korp, const Vektor &gesamtkraft,const float &dt) { - Koerper erg = {0, {0,0}, {0,0}}; - // Berechnung der Beschleunigung aus der Kraft - const float xBeschleunigung = gesamtkraft.x / korp.masse; - const float yBeschleunigung = gesamtkraft.y / korp.masse; - +void Koerper::bewegen(const Vektor &beschleunigung,const float &dt) { // Ermittlung der neuen Geschwindigkeit - erg.geschwindigkeit.x = korp.geschwindigkeit.x + dt * xBeschleunigung; - erg.geschwindigkeit.y = korp.geschwindigkeit.y + dt * yBeschleunigung; + this->geschwindigkeit.x += dt * beschleunigung.x; + this->geschwindigkeit.y += dt * beschleunigung.y; // Ermittlung der neuen Position - erg.position.x += korp.position.x + dt * erg.geschwindigkeit.x; - erg.position.y += korp.position.y + dt * erg.geschwindigkeit.y; - return erg; + this->position.x += dt * this->geschwindigkeit.x ; + this->position.y += dt * this->geschwindigkeit.y ; } - -void ausgabeKoerper(const Koerper &korp){ - cout << "x = " << korp.position.x << "y = " << korp.position.y; + float Koerper::liefereMasse(){ + return this->masse; } - -void ausgabeVektor(const Vektor &vec){ - cout << "x = " << vec.x << endl; - cout << "y = " << vec.y << endl; +Vektor Koerper::lieferePosition(){ + return this->position; +} + Vektor Koerper::liefereGeschwindigkeit(){ + return this->geschwindigkeit; +} + string Koerper::text(){ + string outputX = to_string(this->position.x); + string outputY = to_string(this->position.y); + stringstream ganzeOut; + ganzeOut << "X= " << outputX << " Y= " << outputY; + return ganzeOut.str(); } diff --git a/5_Flugkurve03/code/flugkurve03.h b/5_Flugkurve03/code/flugkurve03.h index 367f366..4c908aa 100644 --- a/5_Flugkurve03/code/flugkurve03.h +++ b/5_Flugkurve03/code/flugkurve03.h @@ -19,20 +19,18 @@ public: }; // Körper: class Koerper { +public: float masse; // [kg] Vektor position; Vektor geschwindigkeit; - -public: Koerper(float masse, Vektor position, Vektor geschwindigkeit) { this->masse = masse; this->position = position; this->geschwindigkeit = geschwindigkeit; }; float liefereMasse(); - Koerper bewegeKoerper(const Koerper &korp, const Vektor &gesamtkraft, const float &dt); + void bewegen(const Vektor &gesamtkraft, const float &dt); Vektor lieferePosition(); Vektor liefereGeschwindigkeit(); - void bewegen(Vektor beschleunigung, float dt); string text(); };