![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol/src/Math/Polygon.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _Vec = _interopRequireDefault(require("./Vec2")); /*** * * @param {Vec2[]} vertices * @constructor */ function Polygon(vertices) { this.vertices = vertices; } /*** * * @param {Vec2} P * @returns {-1|0|1} */ Polygon.prototype.pointLocalIn = function (P) { var A = this.vertices[this.vertices.length - 1]; var B; var AB, PA, PB; var t, x; var count = 0; for (var i = 0; i < this.vertices.length; ++i) { B = this.vertices[i]; PA = A.sub(P); PB = B.sub(P); if (PA.cross(PB) === 0 && PA.dot(PB) <= 0) { return 0; } AB = B.sub(A); if (A.y !== B.y) { t = -PA.y / AB.y; x = A.x + AB.x * t; if (t >= 0 && t < 1 && x > P.x) { count++; } } A = B; } return count % 2 === 1 ? 1 : -1; }; Polygon.prototype.getPathString = function () { var vts = this.vertices; var res = 'M' + vts[0].x + ' ' + vts[0].y; for (var i = 1; i < vts.length; ++i) { res += 'L' + vts[i].x + ' ' + vts[i].y; } res += 'z'; return res; }; Polygon.prototype.copy = function () { return new Polygon(this.vertices.map(v => { return v.copy(); })); }; Polygon.make = function (vertices) { return new Polygon(vertices); }; var _default = Polygon; exports.default = _default;