# Check if line intersects a polygon

**URL:** <https://discourse.processing.org/t/check-if-line-intersects-a-polygon/16978>\
**Category:** Coding Questions\
**Created:** [January 9, 2020, 12:29pm UTC](https://discourse.processing.org/t/check-if-line-intersects-a-polygon/16978 "2020-01-09T12:29:11Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![solub](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/solub/32/333_2.png) [@solub](https://discourse.processing.org/u/solub)\
**Post date:** [January 11, 2020, 11:05pm UTC](https://discourse.processing.org/t/check-if-line-intersects-a-polygon/16978/5 "2020-01-11T23:05:03Z")

</div>

Hi @AndreasRef,

Sorry if that doesn’t answer your question but have you tried with a simple line-line [intersection algorithm](https://discourse.processing.org/t/get-intersection-point-of-line-and-cie-chromaticity-curve/6685/7) ?

You could iterate over the edges of your polygon and check if the line intersects at least one of them.

edit: Not sure about this other suggestion either but you could also use the `cast()` function from this [Ray-Casting coding challenge](https://www.youtube.com/watch?v=TOEi6T2mtHo).

---

_[View the full topic](https://discourse.processing.org/t/check-if-line-intersects-a-polygon/16978)._
