Reicher

Parallel line segment intersection

Recommended Posts

I'm working on a little game(http://trans-neptunian-studios.com/Snatris/Beta/) that uses Phaser 2.3.0.

In my game i have a chain of connected lines segments (Phaser.Line). I want to detect when any of these segments intersect. I have found a problem with how Phaser.Line.intersects work. A simple example:

var line1 = new Phaser.Line(0, 0, 100, 0);

var line2 = new Phaser.Line(40, 0, 60, 0);

console.log(line1.intersects(line2));

console.log(line2.intersects(line1));

The two segments line1 and line2 are not only parallel but also on top of each other. Phaser.Line.intersects does not recognize this type of intersection. I understand that in a pure "math-sense" parallel lines cannot intersect or rather they do intersect on infinite many places.

What is the easiest way to detect the "intersection"? Keep in mind that I have many lines in my game and need a general solution.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.