An Algorithm for Triangulating 3D Polygons