triagnulation function