NOTE: I've updated progress at the bottom of the question, so some of my initial issues have been later resolved.
I'm trying to create a Geometry Node group that applies a square cutout pattern to objects (flat plates). So far, I have managed to create a static pattern that works fine if the object is aligned with the global axes, but it doesn't work if the part is rotated.
What I (believe I) need is a vector that describes the long edge of the part. From this, I can find the rotation angle. I tried the bounding box node, but that gives me a box that is aligned to the axis, not one that represents the minimum (smallest) bounding box for that shape. I could also extract the longest edge, but I'm not sure how to do this either.
EDIT: I should add, the geometry is imported from CAD, so I believe it is similar to moving and rotating an object and then applying transformations. I have added an image to better explain the two bounding box methods. Blender's Bounding Box node uses the axis-aligned method, whereas I need an object-aligned method - that is the smallest box that will fit around the object.
EDIT: Strictly speaking - the original question (minimum bounding box or longest edge vector) has been answered (and accepted), however, it has prompted further questions. Please let me know if these should be split off into a separate SE post.
Following on from quellenform's response, I've made further progress. Here's what I've changed.
- The convex hull node was useful for determining the rotation angle, but the longest edge calculation needs to be defined from the aligned bounding box, since the longest edge of the original shape may not correspond to the longest dimension (consider an equilateral triangle shape - the height is greater than any single side). To solve this, I used the rotation angle, to rotate the original geometry, apply the bounding box, then extract the longest and shortest sides.
- New Problem - The longest edge may be a mesh diagonal, not a sharp edge. How can I filter the longest edge calculation to include edges with an 'edge angle' over some threshold?
- New Problem - The rotation angle calculation for some objects needs to be calculated to the X axis, whereas for other objects it needs to be calculated to the Y axis. How can I automate this selection?
- New Problem - The origin point for the original geometry is not always centred on the bounding box. To correct this, I've calculated a translation vector based on the aligned bounding box of the original geometry and the bounding box of the grid. This seems to work, but in many case it aligns close, but not exact. How do I resolve this?
- How do I filter edge calculation for sharp edges only?
- How do I automate the axis selection for angle rotation?
- How do I correct the translation for the grid?