# How to use math to determine if two 2D lines overlap?

**URL:** https://forum.kirupa.com/t/how-to-use-math-to-determine-if-two-2d-lines-overlap/233741
**Category:** programming
**Created:** [July 26, 2007, 3:08pm UTC](https://forum.kirupa.com/t/how-to-use-math-to-determine-if-two-2d-lines-overlap/233741 "2007-07-26T15:08:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![contrast](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@contrast](https://forum.kirupa.com/u/contrast)
#### Post date: [July 26, 2007, 3:08pm UTC](https://forum.kirupa.com/t/how-to-use-math-to-determine-if-two-2d-lines-overlap/233741/1 "2007-07-26T15:08:18Z")

</div>

I am trying to use the Separating Axis Theorem to do collision detection between 2D convex polygons, like shown here:

> **[Games - Welcome to Metanet Software Inc](http://www.metanetsoftware.com/)**
>
> We are Metanet Software, a boutique game developer who created the incredibly popular ninja-parkour platforming games N, N+ and N++. Play them now!

I have projected the vertices of each polygon onto a line and received back two lines. Now I need to see if those lines overlap, and if they do, then what are the coordinates that make up that line (so I can use it later to determine the penetration).

I originally thought I could do a brute force approach and check each possible scenerio, but that is becoming unwieldy, and I am sure there must be a formula to check if two 2D lines overlap, I just can’t seem to find it anywhere.

Using AS 3.0 and CS3.  
Thanks for any help.
