Geometry related code for the pex library