ADD: added the whole tunction to calculate the movement with gegraphiclib
This commit is contained in:
@@ -68,7 +68,7 @@ namespace Entities {
|
|||||||
virtual void specificPhysicsCalculations(std::chrono::milliseconds::rep duration) = 0;
|
virtual void specificPhysicsCalculations(std::chrono::milliseconds::rep duration) = 0;
|
||||||
virtual void specificReloadCharacteristicts() = 0;
|
virtual void specificReloadCharacteristicts() = 0;
|
||||||
|
|
||||||
std::unique_ptr<Entities::Movement> Movement_;
|
std::unique_ptr<Entities::Movement> Movement_ = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
Submodule libs/SimCore updated: eda12f0985...f83fabd343
Submodule libs/json updated: 546370c9e7...a0c1318830
@@ -104,7 +104,13 @@ namespace Entities
|
|||||||
auto end = std::chrono::steady_clock::now();
|
auto end = std::chrono::steady_clock::now();
|
||||||
std::chrono::milliseconds::rep duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
std::chrono::milliseconds::rep duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
||||||
|
|
||||||
Movement_->updatePosition(duration);
|
|
||||||
|
if(Movement_ != nullptr)
|
||||||
|
{
|
||||||
|
// Movement_->updatePosition(duration);
|
||||||
|
Movement_->updatePositionSimple(duration);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
specificPhysicsCalculations(duration);
|
specificPhysicsCalculations(duration);
|
||||||
|
|||||||
@@ -100,8 +100,30 @@ namespace Entities
|
|||||||
|
|
||||||
void Movement::updatePositionSimple(double dt)
|
void Movement::updatePositionSimple(double dt)
|
||||||
{
|
{
|
||||||
|
double lat = ownPosition_.getGeodesicPos()(SimCore::LATITUDE); // in degree
|
||||||
|
double lon = ownPosition_.getGeodesicPos()(SimCore::LONGITUDE); // in degree
|
||||||
|
double alt = ownPosition_.getGeodesicPos()(SimCore::HEIGHT); // in meters
|
||||||
|
|
||||||
|
double vx = this->speed_ * cos(this->getPitch());
|
||||||
|
double vy = this->speed_ * sin(this->getPitch());
|
||||||
|
|
||||||
|
LOG_S(INFO)<<"VX: " << vx << " VY: " <<vy;
|
||||||
|
|
||||||
|
double movedDistance = vx * dt / 1000;
|
||||||
|
double climedHeight = vy * dt / 1000;
|
||||||
|
|
||||||
|
LOG_S(INFO)<<"moved distance: " <<movedDistance;
|
||||||
|
GeographicLib::Geodesic geod(GeographicLib::Constants::WGS84_a(), GeographicLib::Constants::WGS84_f());
|
||||||
|
|
||||||
|
double lat2,lon2;
|
||||||
|
|
||||||
|
geod.Direct(lat,lon,this->course_,movedDistance,lat2,lon2);
|
||||||
|
|
||||||
|
LOG_S(INFO)<< "lat: "<<lat<<" lon: "<<lon;
|
||||||
|
LOG_S(INFO)<< "lat: "<<lat2<<" lon: "<<lon2;
|
||||||
|
ownPosition_.setGeodesicPos(lat2,lon2,climedHeight);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user