Permalink
Browse files

shape

  • Loading branch information...
1 parent 0457c6e commit 28087a5ec8ea308c80cacb228b57686d3b864aa7 @peter-leonov committed Aug 2, 2011
Showing with 8 additions and 8 deletions.
  1. +8 −8 src/modules/vector.js
View
16 src/modules/vector.js
@@ -28,21 +28,21 @@ var Me =
return [s1[0] + u * (e1[0] - s1[0]), s1[1] + u * (e1[1] - s1[1])]
},
- isPointInPoly: function (poly, point)
+ isPointInShape: function (shape, point)
{
// great thank you to _winnie (Пушыстый) http://users.livejournal.com/_winnie/237888.html
var px = point[0], py = point[1]
var intersections = 0
- var prevNum = poly.length - 1,
- prevUnder = poly[prevNum][1] < py
+ var prevNum = shape.length - 1,
+ prevUnder = shape[prevNum][1] < py
- for (var i = 0, il = poly.length; i < il; i++)
+ for (var i = 0, il = shape.length; i < il; i++)
{
- var cur = poly[i],
- prev = poly[prevNum]
+ var cur = shape[i],
+ prev = shape[prevNum]
var curUnder = cur[1] < py
@@ -87,14 +87,14 @@ var Me =
for (var i = 0, il = a.length; i < il; i++)
{
var point = a[i]
- if (this.isPointInPoly(b, point))
+ if (this.isPointInShape(b, point))
points.push(point)
}
for (var i = 0, il = b.length; i < il; i++)
{
var point = b[i]
- if (this.isPointInPoly(a, point))
+ if (this.isPointInShape(a, point))
points.push(point)
}

0 comments on commit 28087a5

Please sign in to comment.