Orienting Polygon to be Parallel to Nearest edge

Hey guys,

I’m trying to get the triangles to be flat/parallel to the nearest edge of the square. As of now all triangles are flat along the x-axis, but am having trouble on figuring out how to expand this concept to adjust to each edge of the square.

Perhaps a potential method is pointing the triangles towards the square’s center then rotating it to the closest perpendicular axis?

triangle orient
triangle orientation.3dm (64.5 KB)
triangle orientation.gh (33.4 KB)

Try two.

triangle orientation-c.gh (19.9 KB

Assumes everything is centered at (0,0,0)

Perfect, thanks for the help

try with align plane.

triangle orientation_2.gh (30.6 KB)

Perfect. A very efficient way of doing this. Thank you!