# Group surfaces by normal

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!

PS: For some reason I can never edit a post on this forum. Here are my edits in bold:

"Here’s a sample of surface vectors I want to group. Also notice how the Math.Abs node turns all Y values into positive numbers that I can then group by (I want to group surfaces having the same X and Y values)

Additional question c) Does anyone have a good example of the node GroupByKey? I can’t seem to find one that explains how this is supposed to work and have been unable to use it in the context of my vector grouping quest.

a. Try with GroupByKey

b. Try with Geometry.Intersect. There must be curve(s) at result if two surfaces share edge(s). You can get bool values from it. DoesIntersect also considerable, but it will return ‘true’ when both surfaces share a point not a curve.

c. See attached image at “a”. It makes sublists by queried values.

1 Like

Thanks, this should work.