MCPcopy Create free account
hub / github.com/plotly/plotly.js / isPtInsidePolygon

Function isPtInsidePolygon

src/plots/polar/helpers.js:22–39  ·  view source on GitHub ↗

* is pt (r,a) inside polygon made up vertices at angles 'vangles' * inside a given polar sector * * @param {number} r : pt's radial coordinate * @param {number} a : pt's angular coordinate in *radians* * @param {2-item array} rBnds : sector's radial bounds * @param {2-item array} aBnds : secto

(r, a, rBnds, aBnds, vangles)

Source from the content-addressed store, hash-verified

20 * @return {boolean}
21 */
22function isPtInsidePolygon(r, a, rBnds, aBnds, vangles) {
23 if(!isAngleInsideSector(a, aBnds)) return false;
24
25 var r0, r1;
26
27 if(rBnds[0] < rBnds[1]) {
28 r0 = rBnds[0];
29 r1 = rBnds[1];
30 } else {
31 r0 = rBnds[1];
32 r1 = rBnds[0];
33 }
34
35 var polygonIn = polygonTester(makePolygon(r0, aBnds[0], aBnds[1], vangles));
36 var polygonOut = polygonTester(makePolygon(r1, aBnds[0], aBnds[1], vangles));
37 var xy = [r * Math.cos(a), r * Math.sin(a)];
38 return polygonOut.contains(xy) && !polygonIn.contains(xy);
39}
40
41// find intersection of 'v0' <-> 'v1' edge with a ray at angle 'a'
42// (i.e. a line that starts from the origin at angle 'a')

Callers

nothing calls this directly

Calls 2

isAngleInsideSectorFunction · 0.85
makePolygonFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…