implemented triangulation