# Line-Line intersection for y=mx+c

**URL:** https://discourse.processing.org/t/line-line-intersection-for-y-mx-c/26484
**Category:** Coding Questions
**Created:** [December 23, 2020, 10:27pm UTC](https://discourse.processing.org/t/line-line-intersection-for-y-mx-c/26484 "2020-12-23T22:27:34Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [December 23, 2020, 10:30pm UTC](https://discourse.processing.org/t/line-line-intersection-for-y-mx-c/26484/2 "2020-12-23T22:30:43Z")

</div>

> [@Trying to understand the "Substrate" algorithm](https://discourse.processing.org/t/trying-to-understand-the-substrate-algorithm/3031/10):
>
> Hi @solub. Here is an example of line-line collision detection – it returns true-false, but you can also return a PVector with the intersection point, which is very useful for truncating a growing line at exactly the right place after it crosses. /\*\* \* Line-Line collision detection \* http://www.jeffreythompson.org/collision-detection/line-line.php \*/ boolean lineLine(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) { // calculate the distance to intersection…

---

_[View the full topic](https://discourse.processing.org/t/line-line-intersection-for-y-mx-c/26484)._
