I am attempting to write a function (programming, not mathematics) which calculates the shortest distance between two points on a toroid. I got the following formula from StackOverflow, but I don't recognize the
min portion. Can someone explain that to me, please?
sqrt(min(|x1 - x2|, w - |x1 - x2|)^2 + min(|y1 - y2|, h - |y1-y2|)^2)