fixed a bug in calculating the intersection of the tangent lines