Suppose we have an arrangement of points in 2D that are visually symmetric, and therefore they have a rotation that seems "natural".
For example, consider these points:
pts = {{0, 0}, {2, 0}, {0, 1}, {2, 1}};
rpts = pts.RotationMatrix[RandomReal[2 Pi]];
rpts = # + RandomReal[0.01 {-1, 1}, 2] & /@ rpts;
Graphics[{PointSize[0.05], Point[rpts]}]
It would be nicer to draw them like this:
In this particular case, this can be achieved with principal component analysis:
Graphics[{PointSize[0.05], Point[PrincipalComponents@rpts]}]
However, this approach fails when the points have an (approximate) rotational symmetry:
pts = {{0, 0}, {1, 0}, {0, 1}, {1, 1}};
rpts = pts.RotationMatrix[RandomReal[2 Pi]];
rpts = # + RandomReal[0.01 {-1, 1}, 2] & /@ rpts;
Graphics[{PointSize[0.05], Point[PrincipalComponents@rpts]}]
pts = CirclePoints[6];
rpts = pts.RotationMatrix[RandomReal[2 Pi]];
rpts = # + RandomReal[0.01 {-1, 1}, 2] & /@ rpts;
Graphics[{PointSize[0.05], Point[PrincipalComponents@rpts]}]
Question: What method would work better in these nearly rotationally symmetric cases, while also being able to handle any other case?
Application: Rotating graph layouts obtained with force-directed methods (which often produce symmetric results if the graph has symmetries).
Here's a more complicated point set for testing:
pts = Uncompress[
"1:eJwBUQGu/iFib1JlAgAAABQAAAACAAAA9NeXQqZd6T8vLQSgIiOyP3FgrKVIVum/\
jpcK2AsTs78cwn5lTgbUP1LqwmkTaOe/gfuthKTXxj+NFQSPAcToP9aS8KD+K+O/\
V586UvPa4L/llJnBFw7mv7b6zL0pJ9o/kyJOEEMbxT/RsQ4owyDZv55vXyqkybY/\
qEKnmNK92j9MEeOEUf7XP/XZ8IOQDcy/HL1oVXsV1T8FPrI3VVPSP0CYVbBz/tS/u3P7y/\
f+0b84R93SiCfYv54206OWhMw/fo+y4Bvs2r+2kJ5NEImkv6K1ic6w9eU/9UOI0wkR2r/\
50WjzpEzjP6aCSvzg2+A/7wIJEZ8T2z+M/dGqofKiP4PFpBk7are/\
1B39elLA2r9LFR1DriPFv8BotjoaNNk/LvMBAYhsxr9tb8rXvt7ov4sIM9IORNS/\
zLGHTttd5z9Yyq9Z"]
~{1,0},{0,1}
. Because there are many symmetries rotation doesn't change the inertia matrix. $\endgroup$ – Ulrich Neumann Feb 16 '18 at 16:08