Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference in distance is not constant for point moving along a horizontal line parallel to the x-axis at a constant speed #161

Open
ttranwork opened this issue May 29, 2018 · 5 comments
Labels

Comments

@ttranwork
Copy link

ttranwork commented May 29, 2018

Hi,
I am trying to find the distance between a moving point p1 and a fixed point p2. Both of them are on the same y-coordinate. Point p1 just travels along the y = b line (n is constant). However, I noticed that while p1 moved at a constant speed, the distance value returned by the SpatialContext.calcDistance(p, p2) didn't change at a constant rate. Below is a sample of my data:

 p1               p2         distance

-141.854 , 52.94 | -106.75 , 52.94 | 1257.386
-140.194 , 52.94 | -106.75 , 52.94 | 1199.061
-138.534 , 52.94 | -106.75 , 52.94 | 1140.57
-136.874 , 52.94 | -106.75 , 52.94 | 1081.92
-135.214 , 52.94 | -106.75 , 52.94 | 1023.121
-133.554 , 52.94 | -106.75 , 52.94 | 964.1811
-131.894 , 52.94 | -106.75 , 52.94 | 905.109
-130.234 , 52.94 | -106.75 , 52.94 | 845.913
-128.574 , 52.94 | -106.75 , 52.94 | 786.6017
-126.914 , 52.94 | -106.75 , 52.94 | 727.1834

As you can see, the change in the x-coordinates between each consecutive snapshot is a constant value of 1.66 degrees. However, the change in distance (1257.386 to 727.1834) between the moving point p1 and the fixed point p2 (-106.75, 52.94) is not a constant value. In fact, the difference is increasing slightly from 58.3245 to 59.4183 between each snapshot. By the way, I used SpatialContext.GEO and Harversine distance calculator for this since my model is geodesic. However, since my point is moving in parallel to the x-axis, I expect the distance delta to be the same. Am I missing something here or am I wrong to assume that? Thanks.

By the way, I forgot to mention that the distance posted is the distance in nautical miles (which I converted from the distance in degree by multiplying the result with DistanceUtils.DEG_TO_KM * KM_TO_NAUTICAL_MILE).

@ttranwork ttranwork changed the title Difference in distance is not constant for points moving along a horizontal line parallel to the x-axis at a constant speed Difference in distance is not constant for point moving along a horizontal line parallel to the x-axis at a constant speed May 29, 2018
@dsmiley
Copy link
Contributor

dsmiley commented May 29, 2018

However, since my point is moving in parallel to the x-axis, I expect the distance delta to be the same. Am I missing something here or am I wrong to assume that?

Yes you are wrong to assume that but don't feel bad; geodesics are non-obvious ;-) This is hard for me to explain; I guess I could put it back to you as to why you think the rate should be the same? Relative to p2, point p1 "looks" like it's moving in a curve relative to itself, and that means a non-constant change in distance at each point. Perhaps if you plot it on a globe/sphere, it may be more apparent. I confess I don't have a tip on how to do that easily.

@ttranwork
Copy link
Author

ttranwork commented May 30, 2018

I guess it's not moving at a constant rate. But I'm still confused when it comes to the distance delta and the degree delta. If I move 1 degree of longitude (same latitude) every minute, shouldn't I expect the distance to be reduced by one degree every minute as well?

@dsmiley
Copy link
Contributor

dsmiley commented May 30, 2018

No. Look at the top of a globe. Pick a high latitude, like 80 degrees. Say this is the line of longitude your p1 is moving along. It's a circle/curved. If you put p2 below 80 degrees somewhat, a few degrees perhpas, and imagine looking at p1 move about along this line.

@ttranwork
Copy link
Author

ttranwork commented May 30, 2018

Hmm, let's say I have two points with the same latitude and are exactly 5 degrees of longitude apart. If I start from one point and move to the other point at exactly 1 degree of longitude (on the same latitude circle) every minute, how come the distance between myself and the destination point is not decreased by exactly one degree at every minute? After all, isn't it true that for every arc on the same circle with the same arc degree, they all have the same arc length as well?

@rwema3
Copy link

rwema3 commented Jun 15, 2022

It's not traveling at a consistent speed, I guess. However, when it comes to the distance delta and the degree delta, I'm still perplexed. Shouldn't I anticipate the distance to be lowered by one degree every minute if I move one degree of longitude (same latitude)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants