implementing triangulation