-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/geom-qe' into develop
* feature/geom-qe: docs(geom): update readme feat(geom-voronoi): re-import & update QE delaunay/voronoi pkg (MBP2010) feat(quad-edge): re-import & update quad edge impl (MBP2010) refactor(geom): minor update clippedLine() refactor(geom-clip): minor update liangBarsky refactor(geom): swap Group ctor & factory arg order build(geom): update geom-clip dep & refs build(geom-clip): rename pkg geom-clip-convex => geom-clip, update deps refactor(geom-tessellate): update imports / deps feat(math): add simplifyRatio() refactor(geom): update pointInside & classifyPoint impls (delegate) feat(geom-poly-utils): add convexity(), remove obsolete/migrated point checks feat(geom-api): re-add Convexity enum feat(geom-isec): migrate point intersection/containment checks minor(geom-closest-point): minor updates docs(vectors): update docstrings
- Loading branch information
Showing
53 changed files
with
1,508 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Polygon convexity classifier. | ||
*/ | ||
export const enum Convexity { | ||
ILLEGAL = -1, | ||
COLINEAR = 0, | ||
CONVEX, | ||
CONCAVE, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { EPS } from "@thi.ng/math"; | ||
import { Vec } from "@thi.ng/vectors"; | ||
|
||
/** | ||
* Performs Liang-Barsky clipping of the line segment with endpoints | ||
* `a`, `b` against the clipping rect defined by `min` and `max`. The | ||
* optional `ca` and `cb` vectors can be given to store the result | ||
* (clipped points). If omitted creates new vectors. Returns a tuple of | ||
* `[ca, cb, a, b]`, where the latter two values represent the | ||
* normalized distances of the clipped points relative to original given | ||
* line segment. Returns `undefined` iff the line lies completely | ||
* outside the rect. | ||
* | ||
* https://en.wikipedia.org/wiki/Liang%E2%80%93Barsky_algorithm | ||
* https://github.com/thi-ng/c-thing/blob/master/src/geom/clip/liangbarsky.c | ||
* | ||
* @param a | ||
* @param b | ||
* @param min | ||
* @param max | ||
* @param ca | ||
* @param cb | ||
*/ | ||
export const liangBarsky2 = ( | ||
a: Vec, | ||
b: Vec, | ||
min: Vec, | ||
max: Vec, | ||
ca?: Vec, | ||
cb?: Vec | ||
): [Vec, Vec, number, number] => { | ||
const ax = a[0]; | ||
const ay = a[1]; | ||
const dx = b[0] - ax; | ||
const dy = b[1] - ay; | ||
let alpha = 0; | ||
let beta = 1; | ||
|
||
const clip = (p: number, q: number) => { | ||
if (q < 0 && Math.abs(p) < EPS) { | ||
return false; | ||
} | ||
const r = q / p; | ||
if (p < 0) { | ||
if (r > beta) { | ||
return false; | ||
} else if (r > alpha) { | ||
alpha = r; | ||
} | ||
} else { | ||
if (r < alpha) { | ||
return false; | ||
} else if (r < beta) { | ||
beta = r; | ||
} | ||
} | ||
return true; | ||
}; | ||
|
||
if (!( | ||
clip(-dx, -(min[0] - ax)) && | ||
clip(dx, max[0] - ax) && | ||
clip(-dy, -(min[1] - ay)) && | ||
clip(dy, max[1] - ay) | ||
)) { | ||
return; | ||
} | ||
|
||
!ca && (ca = []); | ||
!cb && (cb = []); | ||
|
||
ca[0] = alpha * dx + ax; | ||
ca[1] = alpha * dy + ay; | ||
cb[0] = beta * dx + ax; | ||
cb[1] = beta * dy + ay; | ||
|
||
return [ca, cb, alpha, beta]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/geom-clip-convex/test/index.ts → packages/geom-clip/test/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// import * as assert from "assert"; | ||
// import * as gc from "../src/index"; | ||
|
||
describe("geom-clipconvex", () => { | ||
describe("geom-clip", () => { | ||
it("tests pending"); | ||
}); |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.