If appropriate space partitioning techniques are used, the complexity of the intersection calculations can be reduced from O(M N) to O(M+N). Since not sufficient amount of literature for classifying and handling the special cases was available at the time of writing of the code, a trial and error method was adopted to arrive at an algorithm to classify all the special cases known. Since the algorithm is not rigorously tested, there might just be a very very special case for which it may fail.