triangulation operation code with c++