Compare commits
1
Commits
A5
..
3b94f5d1b1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b94f5d1b1 |
No files matched your search
Binary file not shown.
@@ -15,28 +15,27 @@ void Vektor::add(const Vektor &vec2) {
|
||||
this->y += vec2.y;
|
||||
}
|
||||
|
||||
void Koerper::bewegen(const Vektor &beschleunigung,const float &dt) {
|
||||
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;
|
||||
|
||||
// Ermittlung der neuen Geschwindigkeit
|
||||
this->geschwindigkeit.x += dt * beschleunigung.x;
|
||||
this->geschwindigkeit.y += dt * beschleunigung.y;
|
||||
erg.geschwindigkeit.x = korp.geschwindigkeit.x + dt * xBeschleunigung;
|
||||
erg.geschwindigkeit.y = korp.geschwindigkeit.y + dt * yBeschleunigung;
|
||||
|
||||
// Ermittlung der neuen Position
|
||||
this->position.x += dt * this->geschwindigkeit.x ;
|
||||
this->position.y += dt * this->geschwindigkeit.y ;
|
||||
erg.position.x += korp.position.x + dt * erg.geschwindigkeit.x;
|
||||
erg.position.y += korp.position.y + dt * erg.geschwindigkeit.y;
|
||||
return erg;
|
||||
}
|
||||
float Koerper::liefereMasse(){
|
||||
return this->masse;
|
||||
|
||||
void ausgabeKoerper(const Koerper &korp){
|
||||
cout << "x = " << korp.position.x << "y = " << korp.position.y;
|
||||
}
|
||||
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();
|
||||
|
||||
void ausgabeVektor(const Vektor &vec){
|
||||
cout << "x = " << vec.x << endl;
|
||||
cout << "y = " << vec.y << endl;
|
||||
}
|
||||
@@ -19,18 +19,20 @@ 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();
|
||||
void bewegen(const Vektor &gesamtkraft, const float &dt);
|
||||
Koerper bewegeKoerper(const Koerper &korp, const Vektor &gesamtkraft, const float &dt);
|
||||
Vektor lieferePosition();
|
||||
Vektor liefereGeschwindigkeit();
|
||||
void bewegen(Vektor beschleunigung, float dt);
|
||||
string text();
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
# Klassen:
|
||||
- Verkehrsmittel
|
||||
- Posistion (int x, int y)
|
||||
- bewegen(neue Posistion)
|
||||
- Luftfahrzeuge
|
||||
- max. Flughöhe
|
||||
- Radfahrzeuge
|
||||
- Anzahl Räder
|
||||
- Pkw
|
||||
- Anzahl Türen
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
class Luftfahrzeug{
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
class PKW{};
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
class Radfahrzeug{};
|
||||
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
class Verkehrsmittel{
|
||||
};
|
||||
Reference in new issue
Block a user