Reputation: 31
I'm trying to implement a Weiler-Atherton
clipping algorithm. I've read around a lot, and looked at sample code, and I can't seem to find anyone who talks about collinear line segments and how to deal with them.
For example, the two rectangles
[[0, 0], [0, 1], [3, 1], [3, 0]]
and [[1, 0], [1, 2], [2, 2], [2, 0]]
have two overlapping line segments --[[3, 0], [0, 0]]
overlaps with [[2, 0], [1, 0]]
.
Most code I've read will treat these as parallel line segments and leaves out the intersection completely. Is that the best thing to do?
Upvotes: 1
Views: 852
Reputation: 31
So, right now, I think the answer is "ignore them". The two vertices of the overlap will also be intersections of other (non-colinear) line segments, so you can just handle them when dealing with those intersections.
Upvotes: 1