C
C#5mo ago
Misken

Gps interpolation problem

I'm having problems getting the correct results from interpolation of positions with time (x,y,t) to gps recorded positions with time interval Is there anyone who can point me in the right direction? Posting the problem desccription and the closest I got so far
2 Replies
Tvde1
Tvde15mo ago
You're going to need to help us a bit more for us to help you correctly. Where in the code do you think it's going wrong? Have you tried debugging?
Misken
Misken5mo ago
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; }