triangulation algo