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 {
   x1=MIN(x1,p.x)
   x2=MAX(x2,p.x)
   y1=MIN(y1,p.y)
   y2=MAX(y2,p.y)
}
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…