(x0, y0, x1, y1, x2, y2, x3, y3)
| 23 | } |
| 24 | |
| 25 | function intersect(x0, y0, x1, y1, x2, y2, x3, y3) { |
| 26 | var x10 = x1 - x0, y10 = y1 - y0, |
| 27 | x32 = x3 - x2, y32 = y3 - y2, |
| 28 | t = y32 * x10 - x32 * y10; |
| 29 | if (t * t < epsilon) return; |
| 30 | t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t; |
| 31 | return [x0 + t * x10, y0 + t * y10]; |
| 32 | } |
| 33 | |
| 34 | // Compute perpendicular offset line of length rc. |
| 35 | // http://mathworld.wolfram.com/Circle-LineIntersection.html |