0

I have an Area (blue) and two points from which I form a Line. I would like to check for intersection between these two objects. I tried converting the line to an area with a small width but this doesn't work as the lines gradient is not limited to 0 or undefined.

Visualisation

Alternatively, if this isn't the easiest way to check for line of sight between two points, please advise me otherwise.

callan
  • 1
  • 2
  • The image reminds me of the answer that I posted at https://stackoverflow.com/a/23971327/3182664, which contains such intersection checks as one tiny building block. More information about your current *representation* of the geometry could be helpful. Are these indeed `java.awt.geom.Line2D` objects etc? However, as Joe C pointed out, there are most likely already answers for this. – Marco13 Feb 20 '18 at 23:50
  • @Marco13 java.awt.geom.Area and java.awt.geom.Line2D are used – callan Feb 20 '18 at 23:56
  • Well, the code in the answer that I linked to contains a `Shapes` class that can convert a `Shape` into a list of line segments, and an `Intersection` class that computes the intersection between two line segments. If you haven't found an answer here on stackoverflow yet, then your question must be far more specific. – Marco13 Feb 21 '18 at 00:27
  • @Marco13 A suggestion in the thread you linked found me my easiest solution. It doesn't need to be 100% accurate so I create an area from the line (i.e. 4 point polygon where 2 of the points are just the start and finish slightly offset) then checked for collision this way. Thanks – callan Feb 21 '18 at 00:40
  • @callan was your question answered? –  Feb 21 '18 at 01:17

0 Answers0