OPR-PR/5_Flugkurve03/code/flugkurve03.cpp

43 lines
1.1 KiB
C++

#include <string>
#include <iostream>
#include <sstream>
#include "flugkurve03.h"
using namespace std;
void Vektor::mul(const float &skalar){
this->x *= skalar;
this->y *= skalar;
}
void Vektor::add(const Vektor &vec2) {
this->x += vec2.x;
this->y += vec2.y;
}
void Koerper::bewegen(const Vektor &beschleunigung,const float &dt) {
// Ermittlung der neuen Geschwindigkeit
this->geschwindigkeit.x += dt * beschleunigung.x;
this->geschwindigkeit.y += dt * beschleunigung.y;
// Ermittlung der neuen Position
this->position.x += dt * this->geschwindigkeit.x ;
this->position.y += dt * this->geschwindigkeit.y ;
}
float Koerper::liefereMasse(){
return this->masse;
}
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();
}