Calculate distance on a wrapped map
So I'm writing code that calculates distance between two cities for civilization 4 (modding, it's a hobby of mine). That's simple enough until you try to figure out how to deal with the wrapped map. I've taken alot of math, been 5 years or so but got through Calc III. But I just can't figure this one out. I've tried googling the answer and got nothing.
What would be a good formula for calculating distance on a wrapped map (ie in a standard cartesian plane if X(max) + 1 = X(min) --also X(min) will always be 1, but X(max) will change depending on the size of the map chosen by the player at game start-the calculation is done on a static map though once it's applied)? All x and y values in this plane are positive integers, not that that's probably important. Also the ability of the x and y values to wrap is independent (can be changed on game setup), so it's best to analyize the x and y seperatly and just apply pythagoras later. Though if that's impossible, I could just set up a bunch of if statements in the code.