Skip to content

Commit

Permalink
feat(geom-clip): enable TS strict compiler flags (refactor)
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 4, 2019
1 parent 4cdbd31 commit 9b6a2ae
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/geom-clip/src/sutherland-hodgeman.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { intersectLineLine } from "@thi.ng/geom-isec";
import { centroid } from "@thi.ng/geom-poly-utils";
import { EPS } from "@thi.ng/math";
import { corner2, ReadonlyVec } from "@thi.ng/vectors";
import { corner2, ReadonlyVec, Vec } from "@thi.ng/vectors";

/**
* Extended version of Sutherland-Hodgeman convex polygon clipping
Expand All @@ -23,7 +23,7 @@ export const sutherlandHodgeman = (
) => {
bc = bc || centroid(bounds);
for (let ne = bounds.length, j = ne - 1, i = 0; i < ne; j = i, i++) {
const clipped = [];
const clipped: Vec[] = [];
const ca = bounds[j];
const cb = bounds[i];
const sign = corner2(ca, cb, bc, eps);
Expand All @@ -33,10 +33,12 @@ export const sutherlandHodgeman = (
const cqsign = corner2(ca, cb, q, eps);
if (corner2(ca, cb, p, eps) === sign) {
clipped.push(
cqsign !== sign ? intersectLineLine(ca, cb, p, q).isec : q
cqsign !== sign
? <Vec>intersectLineLine(ca, cb, p, q).isec
: q
);
} else if (cqsign === sign) {
clipped.push(intersectLineLine(ca, cb, p, q).isec, q);
clipped.push(<Vec>intersectLineLine(ca, cb, p, q).isec, q);
}
}
if (clipped.length < 2) {
Expand Down

0 comments on commit 9b6a2ae

Please sign in to comment.