Changed triangulate to take a locate function as a parameter