Monday, November 30, 2020

Mean polyhedrons

The previous post was a method to find the average polygons of a certain number of sides, assuming that one defines a polygon by its interior angles and edge lengths. 

If we just define shapes by their edge length then we can obtain average triangles and also average tetrahedrons. Without loss of generality, we pick randomly distributed edge lengths which sum to 1.

For triangle edge lengths a,b,c, we get the means (shown over 4 independent trials): 

a,b,c: 0.4, 0.2, 0.4

An isosceles triangle.

when we include reflections, we get an obtuse triangle:

a,b,c: 0.444, 0.361, 0.194


For tetrahedrons we pick 6 edge lengths, and throw out any invalid tetrahedrons. Those being any with faces that disobey the triangle inequality (sum of shortest sides must be greater than longest side) or disobey the tetrahedron inequality (sum of smallest face areas must be greater than the largest face area). 

With these remaining tetrahedra, we find the closest match (dot product of the vector of edge lengths) for all relative orientations. For tetrahedra that is 12 orientations. We convert the mean edge lengths into coordinates like so:

Under this system, the mean tetrahedron is fairly unstable, but seems to look a bit like this:

a,b,c,d,e,f: 0.157258, 0.184638, 0.178683, 0.143683, 0.16418, 0.171558
r
,s,t,u,v:     0.115537, 0.144023, 0.113931, 0.035557, 0.123238

coords: (0,0,0), (0.179,0,0), (0.116, 0.144,0), (0.114, 0.0356, 0.123)

If we allow reflection when matching shapes, then the result look more like this:

a,b,c,d,e,f: 0.195577, 0.184195, 0.126073, 0.159834, 0.193624, 0.140698
r
,s,t,u,v: 0.0458932, 0.178386, 0.0402287, 0.0351516, 0.130161
coords
: (0,0,0), (0.126,0,0), (0.0459, 0.178,0), (0.0402, 0.0352, 0.130)     

Here it is top down: 


Cuboids

For normal right-angled cuboids, we know from the mean signals post that the mean edge lengths must be proportional to 2, 5 and 11:


This is because the cuboid has no further constraints on its edge length, and its symmetries are the same as a length 3 sequence with reflection allowed.


Monday, November 23, 2020

Mean polygons

What does a triangle look like? It is easy to give an answer, but harder to find the best answer: the triangle closest to all others; the mean triangle. The same can be asked of more sided polygons.

Here's my best effort at calculating the mean polygons:

tri: 31, 0.46, 31, 0.27, 118, 0.27. quad: 61, 0.32, 69, 0.32, 61, 0.18, 170, 0.18. pent: 233, 0.08, 70, 0.19, 83, 0.30, 83, 0.24, 70, 0.19.

We can also find the mean of just the convex polygons:


tri: 31, 0.46, 31, 0.27, 118, 0.27. quad: 63, 0.35, 79, 0.20, 109, 0.20, 108, 0.25. pent: 92, 0.32, 91, 0.16, 116, 0.19, 124, 0.18, 117, 0.16.

The asymmetry of two of these is interesting. There are of course two mean shapes in this case, one being the reflection of the other. But whenever you take the mean of this shape with its reflection, the best alignment must on average, create a new mean that looks like the mean shape again (or its reflection). That is what I assume is happening anyway.

If we allow the equivalence class of shapes to include reflections, then we get more asymmetric results:

tri: 16, 0.47, 42, 0.16, 122, 0.37. quad: 32, 0.39, 70, 0.23, 74, 0.16, 184, 0.22. pent: 78, 0.06, 244, 0.22, 57, 0.30, 70, 0.29, 91, 0.12.

And finally, the convex only mean polygons:

 

 
tri: 16, 0.47, 42, 0.16, 122, 0.37. quad: 91, 0.12, 97, 0.22, 135, 0.24, 38, 0.41. pent: 63, 0.36, 110, 0.10, 112, 0.14, 126, 0.22, 129, 0.17.

In order to find these mean polygons, we have to decide what the space of polygons is. 

In my opinion a polygon is defined by a set of interior angles from 0 to 360, and a set of edge lengths. We pick from the set of all such values which produce a valid closed polygon. In practice, we do this by choosing a random set of bearings (from 0 to the expected sum for that polygon), then ordering them and using the adjacent differences as the set of angles. This gives a uniformly distributed set of angles such that they add up to the expected total. We do the same thing for edge lengths. We then check whether the resulting polygon is close to being closed. If it isn't, we throw it out. If it is then we adjust the edge lengths to pull it together (this should only introduce a tiny error if any).

Now we can generate random polygons, we need to decide how to average them. We shouldn't just average the parameters (angles and lengths) because these are shapes, and shapes are an equivalence class. Usually, shapes remain the same shape under Euclidean transformations and scaling. So I average each pair of n-sided polygons together by comparing against all n relative rotations and taking the sum of the products of the interior angles, and multiplying it by the sum of the products of the edge lengths. This is a form of cross correlation, and the greatest match defines how one polygon is rotated relative to the other. We take the mean of the polygon parameters once they are matched (shifted around the loop to be as close as possible). We therefore take the mean of pairs, then take the mean of pairs of these, and so on. The reason I don't just accumulate a running mean, is that I don't want symmetry breaking, where a particular bias then is strengthened.