3 Commits
A4 ... A5
Author SHA1 Message Date
kachelto100370 cf97b0ac1e alle Test laufen durch 2026-05-12 17:41:40 +02:00
kachelto100370 fada2730bf added all missing functionis 2026-05-09 15:46:45 +02:00
kachelto100370 b636977ccd alle methoden die ich brauche sind deklariert 2026-05-07 16:53:07 +02:00
3 changed files with 28 additions and 29 deletions
BIN
View File
Binary file not shown.
+25 -24
View File
@@ -5,37 +5,38 @@
using namespace std;
Vektor Vektor::mulVektor(const Vektor &vec, const float &skalar){
Vektor ergebnis = {vec.x * skalar, vec.y * skalar};
return ergebnis;
void Vektor::mul(const float &skalar){
this->x *= skalar;
this->y *= skalar;
}
Vektor addVektor(const Vektor &vec1, const Vektor &vec2) {
Vektor erg = {x + x, y + y};
return erg;
void Vektor::add(const Vektor &vec2) {
this->x += vec2.x;
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();
}
+3 -5
View File
@@ -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();
};