construct a bounding rectangle

I have 8 points and want to construct a bounding rectangle with that has anyone good resources on how this is done since I cannot figure it out …

for an axis aligned rectangle it is quite easy, pseudocode :

for all points p in list {
rectangle (x1,y1,x2,y2)

the vertices are (x,y,z) I have 8 of them

but want only the outer ones to form that rect - in fact they should build a bottom plane for a penumbra wedge…