Add to the dynamic array in the last argument the edges obtained from a triangle.
In PostGIS a triangle has a single (outer) ring stored as POINTARRAY, which is already closed or implicitly closed