## Correct derivation of angle between two surtopes

Higher-dimensional geometry (previously "Polyshapes").

### Correct derivation of angle between two surtopes

I'm writing a new function in my polytope viewer for calculating angles between surtopes. I'm suddenly starting to realize I've no idea how to do this correctly in all cases.

For facets ((n-1)-dimensional surtopes) it's easy: compute the angle between the normals of the respective hyperplanes.

But for subdimensional surtopes, it's not so clear how to do it correctly. For edges, it's also easy: just calculate the angle between the vectors parallel to the respective edges. But what's the correct derivation for polygons in dimension > 3? Since there would be no unique containing hyperplane that you could use for the computation. And it's not obvious how to derive the containing 2-planes of the two polygons, or how to compute an angle between them (since they wouldn't have unique normals in 4D or higher). If the two polygons lie in the same hyperplane, then you could calculate it within that hyperplane as a subspace, reducing it to the 3D case. But what if they don't lie on the same hyperplane? (Haha, my ignorance is showing.   )

More generally, how to correctly calculate the angle between an i-dimensional surtope I and a j-dimensional surtope J, given their respective vertex coordinates immersed in n-dimensional space? (Assuming they are both incident on some k-dimensional surtope K.)

Currently, my implementation glosses over the problem by taking the centroids of the respective surtopes and the centroid of their shared vertices, and computing the angle based on vectors between those centroids. This works for regular polytopes, but almost everywhere else it's wrong. quickfur
Pentonian

Posts: 2601
Joined: Thu Sep 02, 2004 11:20 pm
Location: The Great White North

### Re: Correct derivation of angle between two surtopes

Here's an initial stab at the problem:

- Consider two polygon surtopes that intersect at an edge. Clearly, the angle between them ought to be defined by the angle between the respective 2-planes they are contained in.
- We can reduce each polygon to a triangle that lies in the same 2-plane, with an edge each coincident on the edge between the two original polygons. This gives us 4 vertices.
- If these 4 vertices are coplanar, then the angle is either 0° or 180°.
- Otherwise, they must form a tetrahedron that spans some 3-plane that contains both of the original polygons. So, compute the plane equations of the 2-plane within this 3-subspace, extract the normal vectors, and compute the angle between them.

We can further generalize this to any two j-surtopes that share a (j-1)-surtope, by using a parallel argument to replace the surtopes with j-simplices sharing a (j-1)-facet, and obtaining either vertices that lie in the same j-plane, in which case the angle is 0° or 180°; or vertices that span a (j+1)-plane, in which case we can compute the plane equations for the two j-planes within the (j+1)-plane (subspace), and measuring the angles between the normal vectors.

However, the above does not address the cases of when two j-surtopes intersect in less than a (j-1)-dimensional surtope. For those cases, things get a lot more complicated: two polygons in 4D, for example, can lie in mutually-orthogonal planes, e.g. an m-gon and an n-gon in a m,n-duoprism, intersecting in a vertex. In this case, we may say the angle ought to be 90°; but it's not clear whether this only applies to duoprisms or if it applies in general. At the very least, if two j-surtopes don't intersect, then there's the possibility that they lie in parallel j-planes, and therefore have no meaningful angle that can be assigned between them. So there are at least two possible angle values for such cases, and it's not clear to me whether other values are possible, or how to distinguish between these two cases if they're the only possibilities.

Also not addressed by the above scheme is the case of computing the angle between a j-surtope and a k-surtope where j≠k. It's not clear how to define such an angle that applies in general, even if for individual cases one may assign one value or another.
quickfur
Pentonian

Posts: 2601
Joined: Thu Sep 02, 2004 11:20 pm
Location: The Great White North

### Re: Correct derivation of angle between two surtopes

This is easy with geometric algebra. The formula for the angle between two k-blades/subspaces A and B is

cos θ = (A~ . B) / (||A|| ||B||)

where ||A|| = sqrt(A~A) is the magnitude of A, and A~ is the reverse of A.

Each blade can be calculated as the wedge product of k many vectors in the subspace: A = a1 ^ a2 ^ ... ^ ak. For a polygon (k=2), these vectors would be two of its edges. We must be consistent with the chirality/order of the vectors in A and B, or we'll get the opposite sign for cos θ.

If two polygons' planes intersect in only a point, then (A~ . B) = 0, so cos θ = 0 (and θ = 90deg). If the planes are parallel, then A is proportional to B, so cos θ = 1 or -1. My formula makes no distinction whether the planes are parallel or coincident; only the orientations of the planes matter, not the exact locations, because each vector is calculated as a difference of two points. (We could account for the exact locations using the (n+2)-dimensional CGA, but that would complicate things.)

I think we can generalize this to j =/= k (with j the grade of A and k the grade of B):

cos θ = ||A~ . B|| / (||A|| ||B||),

but this is always non-negative, so the angle is acute or right.
mr_e_man
Trionian

Posts: 106
Joined: Tue Sep 18, 2018 4:10 am

### Re: Correct derivation of angle between two surtopes

Interesting, what you described is precisely what's presented in this paper: http://gravisma.zcu.cz/GraVisMa-2010/Papers/Full/E05-full.pdf

The GA solution subsumes this other paper I found, that associates an angle between two arbitrary subspaces of n-space computed from a ratio of volumes of parallelopipeds: http://personal.fmipa.itb.ac.id/hgunawan/files/2007/11/guneswan.pdf

In GA, the volume of a parallelopiped is explicitly expressed as the scalar factor of a blade. I seriously need to start working with GA more. It seems to be turning up everywhere I look, and neatly unifies a bunch of otherwise-seemingly-unrelated things in one beautiful package.
quickfur
Pentonian

Posts: 2601
Joined: Thu Sep 02, 2004 11:20 pm
Location: The Great White North

### Re: Correct derivation of angle between two surtopes

And I think you can get non-acute angles if you express the angle using cos^2 θ instead, though I'm unsure exactly what should be on the RHS.
quickfur
Pentonian

Posts: 2601
Joined: Thu Sep 02, 2004 11:20 pm
Location: The Great White North 