Having decided which two sides you will use to define the 'width' you also need to decide how to pair the endpoints. I would do this: find the distance from each of the two endpoints on one side to each of the two endpoints on the other side. That will be a total of 4 values. Pair the two that give the shortest distance and then pair the other two. Find the distance between the two points in each pair, and, finally, average those two numbers.