mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
refs #552 Linear interpolator directly manipulates n-vector instead of converting to lat/lon and back again.
This commit is contained in:
@@ -97,20 +97,14 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const CLatitude oldLat(oldSituation.latitude());
|
const std::array<double, 3> oldVec(oldSituation.getPosition().normalVectorDouble());
|
||||||
const CLatitude newLat(newSituation.latitude());
|
const std::array<double, 3> newVec(newSituation.getPosition().normalVectorDouble());
|
||||||
const CLongitude oldLng(oldSituation.longitude());
|
|
||||||
const CLongitude newLng(newSituation.longitude());
|
|
||||||
|
|
||||||
// Interpolate latitude: Lat = (LatB - LatA) * t + LatA
|
// Interpolate position: pos = (posB - posA) * t + posA
|
||||||
currentPosition.setLatitude((newLat - oldLat)
|
currentPosition.setNormalVector((newVec[0] - oldVec[0]) * simulationTimeFraction + oldVec[0],
|
||||||
* simulationTimeFraction
|
(newVec[1] - oldVec[1]) * simulationTimeFraction + oldVec[1],
|
||||||
+ oldLat);
|
(newVec[2] - oldVec[2]) * simulationTimeFraction + oldVec[2]);
|
||||||
|
|
||||||
// Interpolate latitude: Lon = (LonB - LonA) * t + LonA
|
|
||||||
currentPosition.setLongitude((newLng - oldLng)
|
|
||||||
* simulationTimeFraction
|
|
||||||
+ oldLng);
|
|
||||||
currentSituation.setPosition(currentPosition);
|
currentSituation.setPosition(currentPosition);
|
||||||
|
|
||||||
// Interpolate altitude: Alt = (AltB - AltA) * t + AltA
|
// Interpolate altitude: Alt = (AltB - AltA) * t + AltA
|
||||||
@@ -122,7 +116,7 @@ namespace BlackCore
|
|||||||
+ oldAlt,
|
+ oldAlt,
|
||||||
oldAlt.getReferenceDatum()));
|
oldAlt.getReferenceDatum()));
|
||||||
|
|
||||||
if (!vtolAiracraft && newLat == oldLat && newLng == oldLng && oldAlt == newAlt)
|
if (!vtolAiracraft && newVec == oldVec && oldAlt == newAlt)
|
||||||
{
|
{
|
||||||
// stop interpolation here, does not work for VTOL aircraft. We need a flag for VTOL aircraft
|
// stop interpolation here, does not work for VTOL aircraft. We need a flag for VTOL aircraft
|
||||||
return currentSituation;
|
return currentSituation;
|
||||||
|
|||||||
Reference in New Issue
Block a user