algorithm working without polar method and slope