Misken
Gps interpolation problem
Yes have tried debugging and trying to figure out where I am going wrong
It is the interpolation of the positions that is wrong, the code up until the actualDistance is correct.
Up to that point I just take the input and set up the parameters, the actuaDistance is correctly calculated which means the method "CalculatedDistance" is also correctly using the euclidian distance formula
I am not sure where I am missing something with the calculation of the interpolated positions
So the problem is somewhere in this part within the last for loop
double timeDifference = next.Time - current.Time;
double speedX = (next.X - current.X) / timeDifference;
double speedY = (next.Y - current.Y) / timeDifference;
for (double t = current.Time; t < next.Time; t += gpsRecordingInterval)
{
double interpolatedX = current.X + speedX * (t - current.Time);
double interpolatedY = current.Y + speedY * (t - current.Time);
gpsDistance += CalculateDistance(previousX, previousY, interpolatedX, interpolatedY);
previousX = interpolatedX;
previousY = interpolatedY;
}
3 replies