I'm going to assume that you want all your polygons to meet at one point. Here's how you would do the problem for triangles (it can be easily adapted to quadrilaterals).
Let's suppose in the 2D world your triangles are already arranged so that two of the corresponding pairs of sides are next to each other, and the common point of the triangles is the origin. In other words, let O be the origin, and we have points A, B, C, D so that our three triangles are AOB, BOC, and COD. (You can always apply some transformations to get to this situation.) The task is now to align OA with OD (these are assumed to have the same length) by "folding up" the triangle.* Here's what you would do in pseudocode:
assert(length(OA) == length(OD))
let L_A = line through A perpendicular to OB
let L_D = line through D perpendicular to OC
let E = intersection of L_A and L_D
let z = sqrt(length(OA) * length(OA) - length(OE) * length(OE))
let O' = (0, 0, 0), B' = (B.x, B.y, 0), C' = (C.x, C.y, 0)
let A' = (E.x, E.y, z)
Then, A'O'B'
corresponds to AOB
, B'O'C'
corresponds to BmOC
, and C'O'A'
corresponds to COD
.
*Note: this is only possible if the angles AOB, BOC, and COD sum to less than 360.