I have a list of surfaces (planar) and want to find the vector of the longest line that connects their midpoint. I’m using this to infer direction, then find the angle between vectors.

Initially I placed a point on each surface at U & V =0.5, then did a combination of all the points, passed lines through the combinations and picked the longest line, then found the vector of that line. Even though this approach works, it’s not very efficient when you have a lot of surfaces to compute and a lot of those lines are redundant. A better approach would be to group co-planar surfaces and pass a line through their midpoints instead. Since the surfaces come from a solid box, I know that opposite surfaces are co-planar, yet their vectors are at 180 degrees to each other.

Here are my questions:

a) How do you group a list of vectors by their X & Y values? I can wire the math.Abs node to the XYZs to get around the normals being at 180 degrees to each other

b) Is there a way to tell whether two coplanar surfaces touch each other or share an edge? The reason I care about this is because if there are adjacent planar surfaces, I would want to join them into one surface before finding the midpoint.

Here’s a sample of surface vectors I want to group. Also notice how the Math.Abs node turns all points into positive numbers that I can then group by. Thanks!