|
@@ -35,6 +35,14 @@ export class generate {
|
|
const b = p2.y - k * p2.x;
|
|
const b = p2.y - k * p2.x;
|
|
// 距离两条线l的点 到交点p2的距离
|
|
// 距离两条线l的点 到交点p2的距离
|
|
const Lb2 = l / Math.sin(Math.abs(a1 - a2) / 2);
|
|
const Lb2 = l / Math.sin(Math.abs(a1 - a2) / 2);
|
|
|
|
+ // 特殊情况-角分线垂直或平行X轴
|
|
|
|
+ if (k1 / k2 == -1) {
|
|
|
|
+ if (dx2 * dx1 > 0 && dy2 * dy1 < 0) { // 上下开角
|
|
|
|
+ return [Number((p2.x - Lb2).toFixed(6)), Number(p2.y.toFixed(6)), Number((p2.x + Lb2).toFixed(6)), Number(p2.y.toFixed(6))]
|
|
|
|
+ } else if (dx2 * dx1 < 0 && dy2 * dy1 > 0) { // 左右开角
|
|
|
|
+ return [Number(p2.x.toFixed(6)), Number((p2.y - Lb2).toFixed(6)), Number(p2.x.toFixed(6)), Number((p2.y + Lb2).toFixed(6))]
|
|
|
|
+ }
|
|
|
|
+ }
|
|
// 将距离公式与直线方程连立,并且将直线方程代入,得到一元二次方程 Ax^2 + Bx + C = 0;然后根据得根公式得到2个解
|
|
// 将距离公式与直线方程连立,并且将直线方程代入,得到一元二次方程 Ax^2 + Bx + C = 0;然后根据得根公式得到2个解
|
|
const A = k * k + 1;
|
|
const A = k * k + 1;
|
|
const B = 2 * k * b - 2 * p2.x - 2 * k * p2.y;
|
|
const B = 2 * k * b - 2 * p2.x - 2 * k * p2.y;
|