Download node_modules/d3-geo/src/clip/line.js from NKessler/Horizon: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-geo/src/clip/line.js
- Command line
-
hf download hf://NKessler/Horizon/node_modules/d3-geo/src/clip/line.js
-
curl -L -o line.js https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-geo/src/clip/line.js
1.1 kB
| export default function(a, b, x0, y0, x1, y1) { | |
| var ax = a[0], | |
| ay = a[1], | |
| bx = b[0], | |
| by = b[1], | |
| t0 = 0, | |
| t1 = 1, | |
| dx = bx - ax, | |
| dy = by - ay, | |
| r; | |
| r = x0 - ax; | |
| if (!dx && r > 0) return; | |
| r /= dx; | |
| if (dx < 0) { | |
| if (r < t0) return; | |
| if (r < t1) t1 = r; | |
| } else if (dx > 0) { | |
| if (r > t1) return; | |
| if (r > t0) t0 = r; | |
| } | |
| r = x1 - ax; | |
| if (!dx && r < 0) return; | |
| r /= dx; | |
| if (dx < 0) { | |
| if (r > t1) return; | |
| if (r > t0) t0 = r; | |
| } else if (dx > 0) { | |
| if (r < t0) return; | |
| if (r < t1) t1 = r; | |
| } | |
| r = y0 - ay; | |
| if (!dy && r > 0) return; | |
| r /= dy; | |
| if (dy < 0) { | |
| if (r < t0) return; | |
| if (r < t1) t1 = r; | |
| } else if (dy > 0) { | |
| if (r > t1) return; | |
| if (r > t0) t0 = r; | |
| } | |
| r = y1 - ay; | |
| if (!dy && r < 0) return; | |
| r /= dy; | |
| if (dy < 0) { | |
| if (r > t1) return; | |
| if (r > t0) t0 = r; | |
| } else if (dy > 0) { | |
| if (r < t0) return; | |
| if (r < t1) t1 = r; | |
| } | |
| if (t0 > 0) a[0] = ax + t0 * dx, a[1] = ay + t0 * dy; | |
| if (t1 < 1) b[0] = ax + t1 * dx, b[1] = ay + t1 * dy; | |
| return true; | |
| } | |