algorithm for lines and ellipses using the midpoint 269145