midpoint algorithm for ellipses and lines 464735