vrd / js-intersect

Polygons intersection (JavaScript)
MIT License
56 stars 16 forks source link

Intersect() method crashes #1

Closed Skeptron closed 8 years ago

Skeptron commented 8 years ago

Hi guys!

First I'd like to say how cool your lib is! Pretty hard to find that kind of stuff on the web. Great job.

What license is this code under?

Then I'd like to report a bug (hope you're still willing to fix it). The intersect() method crashes for the following polygons :

var poly0 = [
  {x: 358, y: 0},
  {x: 600, y: 600},
  {x: 800, y: 600},
  {x: 800, y: 500},
  {x: 652, y: 0}
];

var poly1 = [
  {x: 1000, y: 400},
  {x: 400, y: 200},
  {x: 200, y: 200},
  {x: 200, y: 300},
  {x: 449, y: 800},
  {x: 1000, y: 800}
];

They are simple polygons so I see no reason why this should crash. The console trace is : "Polygon.js:155 Uncaught TypeError: Cannot read property 'x' of undefined (solution.js:155)"

If you guys could help me there it would be pretty awesome.

Thanks a lot!

vrd commented 8 years ago

Hi!

I'm pleasantly surprised you interested in this lib. And actually it's not a lib but a decision of entrance task for some advanced JS cources. So this code isn't great-looking, has poor performance on complex polygons and was never heavily tested or used in serious projects.

But anyway, in next couple of days I'll try to solve issues you reported.

Skeptron commented 8 years ago

Nice, thx! Can't wait for a fix. Despite the "not-so-great-looking code", this lib is very promising. Even if I have to do some optimisations later on, it's a great start. :)