0

I am trying to calculate the intersection between 'thick' line segments. That is, lines which, on screen, have quite a thick stroke. This is because they may occasionally need to intersect but in reality lie parallel with either other without their actual centre lines intersecting.

The solution I have at the moment is to treat them as rectangles, which means treating each side as a line segment and testing them all sides of one rectangle against all sides of the other rectangle.

Is there a better way?

Matt W
  • 11,753
  • 25
  • 118
  • 215
  • By "calculating the intersection", do you mean the *region* where they intersect, or a specific position on the center line? Or is it just a boolean query? – meowgoesthedog Aug 15 '17 at 14:59
  • Ideally, the closest point on the segments' centre lines or, if they are parallel to each other, the region. Reducing that down, I will say the region (unless there is a simpler answer, but I wanted to explain where I'm coming from.) – Matt W Aug 15 '17 at 15:01
  • If they are parallel the region computation is quite straightforward (an axis aligned box). Consider the case when they are non-parallel, the intersection point is outside both lines, but the line regions touch. What do you expect to return in this case? (confusion about "closest point") – meowgoesthedog Aug 15 '17 at 15:05
  • That would be the other problem. I would expect a point returned where their strokes touch. (This is why I'm currently going with the bounding box idea.) – Matt W Aug 15 '17 at 16:19
  • Problem is, the stroke rectangles can touch at any number between 1 and 8 points. Not sure it's even possible to define the *best* / "*most representative*" point to choose in the general case. – meowgoesthedog Aug 15 '17 at 16:41
  • Yep. Taking this into consideration, what would be a good way to identify an intersection or even just an overlap of the two segments if treated as rectangles (other than the method I've mentioned)? – Matt W Aug 15 '17 at 22:16
  • 1
    I don't know - maybe the geometric center of the intersect region polygon (seems like the *fairest* way to define it - or at least, the least biased). It would still depend on what you want to do with the intersection result. – meowgoesthedog Aug 15 '17 at 22:26

0 Answers0