mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 03:55:17 +08:00
# Conflicts: # jsowell-ui/.env.development # jsowell-ui/.env.staging # jsowell-ui/bin/build-sit.bat # jsowell-ui/bin/build.bat # jsowell-ui/src/api/adapayMember/adapayMember.js # jsowell-ui/src/api/pile/merchant.js # jsowell-ui/src/router/index.js # jsowell-ui/src/views/financial/financeDetail.vue # jsowell-ui/src/views/financial/merchant.vue # jsowell-ui/src/views/homeIndex/homeIndex.vue # jsowell-ui/src/views/login.vue # jsowell-ui/src/views/pile/basic/detail.vue # jsowell-ui/src/views/pile/station/components/SiteInfo.vue # jsowell-ui/src/views/pile/station/detail.vue # jsowell-ui/src/views/pile/station/orderReport.vue
23 lines
558 B
JavaScript
23 lines
558 B
JavaScript
function windingLine(x0, y0, x1, y1, x, y) {
|
|
if (y > y0 && y > y1 || y < y0 && y < y1) {
|
|
return 0;
|
|
} // Ignore horizontal line
|
|
|
|
|
|
if (y1 === y0) {
|
|
return 0;
|
|
}
|
|
|
|
var dir = y1 < y0 ? 1 : -1;
|
|
var t = (y - y0) / (y1 - y0); // Avoid winding error when intersection point is the connect point of two line of polygon
|
|
|
|
if (t === 1 || t === 0) {
|
|
dir = y1 < y0 ? 0.5 : -0.5;
|
|
}
|
|
|
|
var x_ = t * (x1 - x0) + x0; // If (x, y) on the line, considered as "contain".
|
|
|
|
return x_ === x ? Infinity : x_ > x ? dir : 0;
|
|
}
|
|
|
|
module.exports = windingLine; |