Firstly just to apologise, I posted this on mathoverflow before realising it was focused on research level mathematics.
If I have a regular polygon that is centred at the origin. Then take the difference between all vertices.
Let $U$ = the maximum $x$ difference
Let $V$ = the maximum $y$ difference
I want to figure out the angle of rotation that creates the maximum
$$W = U + V \, .$$
So for example imagine a line (I know it's not a polygon); if the angle of rotation is $0$ then its vertices are at $( 1, 0 )$ and $( -1, 0 )$
$$ U = 1 - (-1) = 2\\ V = 0 - 0 = 0 $$
So $W = 2 + 0 = 2$.
The optimum is 45 degrees of rotation in which case
$$ U = 0.707 - -0.707 = 1.414 \\ V = 0.707 - -0.707 = 1.414 $$
So $W = 2.828$.
If my calculations are correct, an equilateral triangle's optimum is $45$ degrees as well. However its obvious to see the optimum for a square is 0 since the vertices align perfectly with $x,y$ axis (i.e., $(1,0)$, $(0,1)$, $(-1,0)$ and $(0,-1)$).
Hopefully I've explained it well enough. I can find the solution for single instance of the problem using graphs and derivatives BUT it takes a long time. I'm looking for a general purpose algorithm as this is going to be used in some software I'm writing.
Thanks in advance.
PS I forgot to mention that there'll be multiple solutions due to symmetry. So the line's optimum is $45, 135, 225, 315$. I believe the triangles is $15 + 30n$, i.e. $15, 45, 75, \dots$
PPS The vertices are generated using the following formula:
Let $n$ = number of sides
Let $c = 360 / n$
For all $i: 0 \le i \lt n$
$V_i = ( \cos(i \cdot c ), \sin( i \cdot c ) )$
E.g. a regular triangles vertices are:
$V_0 =(\cos(0^\circ), \sin(0^\circ) ) = (1, 0)$
$V_1 =(\cos(120^\circ), \sin(120^\circ) ) = (-0.5, 0.866)$
$V_2 =(\cos(240^\circ), \sin(240^\circ) ) = (-0.5, 0.866)$