Distance between 2 points on a torus
Looking for a really handy function to calculate the distance between 2 points on torus (think 2-dimensional grid that wraps around)?
Here is a simple C# implementation:
public static double Distance(Point a, Point b, int size)
{
int x = Math.Abs(b.X – a.X);
int y = Math.Abs(b.Y – a.Y);
int minX = Math.Min(x, (size – [...]