Skip to content

Commit

Permalink
Adopt d3.Adder
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil committed Jun 10, 2024
1 parent 8000a48 commit 2c54a2a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 45 deletions.
40 changes: 0 additions & 40 deletions src/adder.js

This file was deleted.

8 changes: 3 additions & 5 deletions src/polygonContains.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import adder from "./adder.js";
import {Adder} from "d3-array";
import {cartesian, cartesianCross, cartesianNormalizeInPlace} from "./cartesian.js";
import {asin, atan2, cos, epsilon, pi, quarterPi, sin, tau} from "./math.js";

var sum = adder();

export default function(polygon, point) {
var lambda = point[0],
phi = point[1],
normal = [sin(lambda), -cos(lambda), 0],
angle = 0,
winding = 0;

sum.reset();
const sum = new Adder();

for (var i = 0, n = polygon.length; i < n; ++i) {
if (!(m = (ring = polygon[i]).length)) continue;
Expand Down Expand Up @@ -64,5 +62,5 @@ export default function(polygon, point) {
// from the point to the South pole. If it is zero, then the point is the
// same side as the South pole.

return (angle < -epsilon || angle < epsilon && sum < -epsilon) ^ (winding & 1);
return (angle < -epsilon || angle < epsilon && +sum < -epsilon) ^ (winding & 1);
}

0 comments on commit 2c54a2a

Please sign in to comment.