فهرست منبع

制作新需求

bill 1 سال پیش
والد
کامیت
8806ecd2a7
2فایلهای تغییر یافته به همراه291 افزوده شده و 64 حذف شده
  1. 31 4
      src/graphic/Renderer/Draw.js
  2. 260 60
      src/graphic/Util/MathUtil.js

+ 31 - 4
src/graphic/Renderer/Draw.js

@@ -660,7 +660,7 @@ export default class Draw {
           );
         }
 
-        // console.log(edgeVector);
+        console.log(edgeVector, vector);
         // edgeVector.style = VectorStyle.SingleSolidLine;
         help.drawStyleLine(
           ctx,
@@ -670,11 +670,38 @@ export default class Draw {
         );
 
         if (edgeVector.roadSide) {
-          console.log(edgeVector);
+          const checkLine = [edgeVector.start, edgeVector.end];
+          const targetLine = [
+            vector.roadWidthTipsPos[0].start,
+            vector.roadWidthTipsPos[0].end,
+          ];
+          const isStartMax =
+            mathUtil.getDisForLineCoord(checkLine, targetLine[0]) >
+            mathUtil.getDisForLineCoord(checkLine, targetLine[1]);
+
+          if (!isStartMax) {
+            const temp = targetLine[0];
+            targetLine[0] = targetLine[1];
+            targetLine[1] = temp;
+          }
+
+          const tstart = mathUtil.translate(
+            targetLine[0],
+            targetLine[1],
+            targetLine[1],
+            edgeVector.roadSide.width
+          );
+          const tend = mathUtil.translate(
+            targetLine[0],
+            targetLine[1],
+            targetLine[1],
+            edgeVector.roadSide.width + 24
+          );
+
           help.drawLineText(
             ctx,
-            points[2],
-            points[3],
+            coordinate.getScreenXY(tstart),
+            coordinate.getScreenXY(tend),
             edgeVector.roadSide.width * 10,
             {
               fillColor: isScreenStyle() ? "#000" : "#fff",

+ 260 - 60
src/graphic/Util/MathUtil.js

@@ -32,7 +32,8 @@ export default class MathUtil {
     }
 
     const parametera = (point1.y - point2.y) / (point1.x - point2.x);
-    const parameterb = (point1.x * point2.y - point2.x * point1.y) / (point1.x - point2.x);
+    const parameterb =
+      (point1.x * point2.y - point2.x * point1.y) / (point1.x - point2.x);
     if (this.getFixed(parametera) == 0) {
       return { y: this.getFixed(parameterb) };
     }
@@ -81,7 +82,10 @@ export default class MathUtil {
     var perpendicularVector = { x: -slope, y: 1 };
 
     // 将垂直向量归一化为单位向量
-    var length = Math.sqrt(perpendicularVector.x * perpendicularVector.x + perpendicularVector.y * perpendicularVector.y);
+    var length = Math.sqrt(
+      perpendicularVector.x * perpendicularVector.x +
+        perpendicularVector.y * perpendicularVector.y
+    );
     perpendicularVector.x /= length;
     perpendicularVector.y /= length;
 
@@ -109,7 +113,9 @@ export default class MathUtil {
   }
 
   distanceForPoints(point1, point2) {
-    return Math.sqrt(Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2));
+    return Math.sqrt(
+      Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2)
+    );
   }
 
   //与line平行且两条线直接的距离是distance的两条线
@@ -200,7 +206,10 @@ export default class MathUtil {
     if (angle > 180) {
       angle = 360 - angle;
     }
-    if (Math.abs((angle1 + angle3) / 2 - angle) < Math.abs((angle2 + angle4) / 2 - angle)) {
+    if (
+      Math.abs((angle1 + angle3) / 2 - angle) <
+      Math.abs((angle2 + angle4) / 2 - angle)
+    ) {
       return { p1: point1, p2: point3 };
     } else {
       return { p1: point2, p2: point4 };
@@ -238,7 +247,10 @@ export default class MathUtil {
     if (this.isParallel(parameter1, parameter2)) {
       return null;
     }
-    if (typeof parameter1.a == "undefined" && typeof parameter2.a != "undefined") {
+    if (
+      typeof parameter1.a == "undefined" &&
+      typeof parameter2.a != "undefined"
+    ) {
       if (parameter1.x) {
         return {
           x: parameter1.x,
@@ -250,7 +262,10 @@ export default class MathUtil {
           y: parameter1.y,
         };
       }
-    } else if (typeof parameter2.a == "undefined" && typeof parameter1.a != "undefined") {
+    } else if (
+      typeof parameter2.a == "undefined" &&
+      typeof parameter1.a != "undefined"
+    ) {
       if (parameter2.x) {
         return {
           x: parameter2.x,
@@ -262,10 +277,16 @@ export default class MathUtil {
           y: parameter2.y,
         };
       }
-    } else if (typeof parameter2.a == "undefined" && typeof parameter1.a == "undefined") {
+    } else if (
+      typeof parameter2.a == "undefined" &&
+      typeof parameter1.a == "undefined"
+    ) {
       if (parameter1.hasOwnProperty("x") && parameter2.hasOwnProperty("y")) {
         return { x: parameter1.x, y: parameter2.y };
-      } else if (parameter1.hasOwnProperty("y") && parameter2.hasOwnProperty("x")) {
+      } else if (
+        parameter1.hasOwnProperty("y") &&
+        parameter2.hasOwnProperty("x")
+      ) {
         return { x: parameter2.x, y: parameter1.y };
       } else {
         return null;
@@ -276,8 +297,11 @@ export default class MathUtil {
       return null;
     }
 
-    let joinpointx = (parameter2.b - parameter1.b) / (parameter1.a - parameter2.a);
-    let joinpointy = (parameter1.a * parameter2.b - parameter2.a * parameter1.b) / (parameter1.a - parameter2.a);
+    let joinpointx =
+      (parameter2.b - parameter1.b) / (parameter1.a - parameter2.a);
+    let joinpointy =
+      (parameter1.a * parameter2.b - parameter2.a * parameter1.b) /
+      (parameter1.a - parameter2.a);
 
     let point = { x: joinpointx, y: joinpointy };
     return point;
@@ -294,8 +318,17 @@ export default class MathUtil {
     }
 
     // 线段所在直线的交点坐标 (x , y)
-    const x = ((b.x - a.x) * (d.x - c.x) * (c.y - a.y) + (b.y - a.y) * (d.x - c.x) * a.x - (d.y - c.y) * (b.x - a.x) * c.x) / denominator;
-    const y = -((b.y - a.y) * (d.y - c.y) * (c.x - a.x) + (b.x - a.x) * (d.y - c.y) * a.y - (d.x - c.x) * (b.y - a.y) * c.y) / denominator;
+    const x =
+      ((b.x - a.x) * (d.x - c.x) * (c.y - a.y) +
+        (b.y - a.y) * (d.x - c.x) * a.x -
+        (d.y - c.y) * (b.x - a.x) * c.x) /
+      denominator;
+    const y =
+      -(
+        (b.y - a.y) * (d.y - c.y) * (c.x - a.x) +
+        (b.x - a.x) * (d.y - c.y) * a.y -
+        (d.x - c.x) * (b.y - a.y) * c.y
+      ) / denominator;
 
     return { x: x, y: y };
   }
@@ -307,7 +340,12 @@ export default class MathUtil {
       const x = join.x;
       const y = join.y; // 交点在线段1上 且交点也在线段2上
       /** 2 判断交点是否在两条线段上 **/
-      if ((x - a.x) * (x - b.x) <= 0.001 && (y - a.y) * (y - b.y) <= 0.001 && (x - c.x) * (x - d.x) <= 0.001 && (y - c.y) * (y - d.y) <= 0.001) {
+      if (
+        (x - a.x) * (x - b.x) <= 0.001 &&
+        (y - a.y) * (y - b.y) <= 0.001 &&
+        (x - c.x) * (x - d.x) <= 0.001 &&
+        (y - c.y) * (y - d.y) <= 0.001
+      ) {
         // 返回交点p
         return {
           x: x,
@@ -432,6 +470,18 @@ export default class MathUtil {
     const join = this.getIntersectionPoint(line, verticalLine);
     return join;
   }
+  getDisForLineCoord(line, point) {
+    const [{ x: x1, y: y1 }, { x: x2, y: y2 }] = line;
+    const { x: x3, y: y3 } = point;
+    // 计算直线的斜率
+    const k = (y2 - y1) / (x2 - x1);
+
+    // 计算直线的截距
+    const b = y1 - k * x1;
+
+    // 计算点到直线的距离
+    return Math.abs(k * x3 - y3 + b) / Math.sqrt(k ** 2 + 1);
+  }
 
   // 点到直线的距离
   getDisForPoinLine(point, line) {
@@ -465,7 +515,8 @@ export default class MathUtil {
     if (!minDis) {
       minDis = Constant.minLen;
     }
-    let dis1 = this.getDistance(startPoint, point) + this.getDistance(endPoint, point);
+    let dis1 =
+      this.getDistance(startPoint, point) + this.getDistance(endPoint, point);
     let dis2 = this.getDistance(startPoint, endPoint);
     if (Math.abs(dis1 - dis2) < minDis) {
       return true;
@@ -533,7 +584,8 @@ export default class MathUtil {
       const xj = pt2.x;
       const yj = pt2.y;
 
-      const intersect = yi > y != yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi;
+      const intersect =
+        yi > y != yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi;
       if (intersect) inside = !inside;
     }
 
@@ -542,7 +594,9 @@ export default class MathUtil {
 
   //a表示横轴,b表示竖轴
   isPointInElliptic(point, center, a, b) {
-    let r = Math.pow((point.x - center.x) / a, 2) + Math.pow((point.y - center.y) / b, 2);
+    let r =
+      Math.pow((point.x - center.x) / a, 2) +
+      Math.pow((point.y - center.y) / b, 2);
 
     if (r <= 1) {
       return true;
@@ -560,7 +614,10 @@ export default class MathUtil {
     const dis = this.getDistance(point1, point2);
     const dis1 = this.getDistance(join, point1);
     const dis2 = this.getDistance(join, point2);
-    if (this.getDistance(join, point1) > dis || this.getDistance(join, point2) > dis) {
+    if (
+      this.getDistance(join, point1) > dis ||
+      this.getDistance(join, point2) > dis
+    ) {
       // 在线段外
       if (dis1 < dis2 && dis1 < minDistance) {
         return { type: 1, join: point1 };
@@ -581,7 +638,10 @@ export default class MathUtil {
   }
 
   PointInSegment(Q, pi, pj, minDis) {
-    if (this.getDistance(Q, pi) < Constant.minAdsorbPix || this.getDistance(Q, pj) < Constant.minAdsorbPix) {
+    if (
+      this.getDistance(Q, pi) < Constant.minAdsorbPix ||
+      this.getDistance(Q, pj) < Constant.minAdsorbPix
+    ) {
       return true;
     }
 
@@ -636,7 +696,11 @@ export default class MathUtil {
     const dot_product_AP = AP.x * AB_direction.x + AP.y * AB_direction.y;
     const dot_product_BP = BP.x * AB_direction.x + BP.y * AB_direction.y;
     //return dot_product_AP >= 0 && dot_product_BP <= 0 && Math.abs(AP.x * BP.y - AP.y * BP.x) <= AB_length * Number.EPSILON;
-    return dot_product_AP >= 0 && dot_product_BP <= 0 && Math.abs(AP.x * BP.y - AP.y * BP.x) <= 0.01;
+    return (
+      dot_product_AP >= 0 &&
+      dot_product_BP <= 0 &&
+      Math.abs(AP.x * BP.y - AP.y * BP.x) <= 0.01
+    );
   }
 
   clonePoint(p1, p2) {
@@ -695,7 +759,12 @@ export default class MathUtil {
     }
     const join = this.getIntersectionPoint2(point1, point2, point3, point4);
     if (join != null) {
-      if (this.getDistance(point1, join) > dis && this.getDistance(point2, join) > dis && this.getDistance(point3, join) > dis && this.getDistance(point4, join) > dis) {
+      if (
+        this.getDistance(point1, join) > dis &&
+        this.getDistance(point2, join) > dis &&
+        this.getDistance(point3, join) > dis &&
+        this.getDistance(point4, join) > dis
+      ) {
         if (
           this.getDistance(point1, join) < this.getDistance(point1, point2) &&
           this.getDistance(point2, join) < this.getDistance(point1, point2) &&
@@ -708,7 +777,10 @@ export default class MathUtil {
         }
       }
     } else {
-      if (this.PointInSegment(point1, point3, point4) || this.PointInSegment(point2, point3, point4)) {
+      if (
+        this.PointInSegment(point1, point3, point4) ||
+        this.PointInSegment(point2, point3, point4)
+      ) {
         return true;
       }
     }
@@ -814,7 +886,8 @@ export default class MathUtil {
       return 0;
     }
     let s = points[0].y * (points[point_num - 1].x - points[1].x);
-    for (let i = 1; i < point_num; ++i) s += points[i].y * (points[i - 1].x - points[(i + 1) % point_num].x);
+    for (let i = 1; i < point_num; ++i)
+      s += points[i].y * (points[i - 1].x - points[(i + 1) % point_num].x);
     return Math.abs(s / 2.0);
   }
 
@@ -822,7 +895,13 @@ export default class MathUtil {
   getPolygonCore(points) {
     function Area(p0, p1, p2) {
       let area = 0.0;
-      area = p0.x * p1.y + p1.x * p2.y + p2.x * p0.y - p1.x * p0.y - p2.x * p1.y - p0.x * p2.y;
+      area =
+        p0.x * p1.y +
+        p1.x * p2.y +
+        p2.x * p0.y -
+        p1.x * p0.y -
+        p2.x * p1.y -
+        p0.x * p2.y;
       return area / 2;
     }
 
@@ -1290,9 +1369,15 @@ export default class MathUtil {
 
     let delta;
     if (v > 1) {
-      delta = this.pointMinus(p1, this.pointPlus(pt, this.pointScale(this.pointMinus(p2, pt), 1 / v)));
+      delta = this.pointMinus(
+        p1,
+        this.pointPlus(pt, this.pointScale(this.pointMinus(p2, pt), 1 / v))
+      );
     } else {
-      delta = this.pointMinus(this.pointPlus(pt, this.pointScale(this.pointMinus(p1, pt), v)), p2);
+      delta = this.pointMinus(
+        this.pointPlus(pt, this.pointScale(this.pointMinus(p1, pt), v)),
+        p2
+      );
     }
     delta = this.pointScale(delta, scale);
 
@@ -1311,7 +1396,12 @@ export default class MathUtil {
     const curves = [];
     let preControl1, preControl2;
     for (let i = 0; i < points.length - 2; i++) {
-      const { control1, control2 } = this.getCurvesControls(points[i], points[i + 1], points[i + 2], scale);
+      const { control1, control2 } = this.getCurvesControls(
+        points[i],
+        points[i + 1],
+        points[i + 2],
+        scale
+      );
 
       curves.push({
         start: points[i],
@@ -1374,7 +1464,9 @@ export default class MathUtil {
       const xs1 = m1 < 0 ? -1 : 1;
       const xs2 = m2 < 0 ? -1 : 1;
 
-      t1 = (-b - (m1 * xs1) ** (1 / 3) * xs1 - (m2 * xs2) ** (1 / 3) * xs2) / (3 * a);
+      t1 =
+        (-b - (m1 * xs1) ** (1 / 3) * xs1 - (m2 * xs2) ** (1 / 3) * xs2) /
+        (3 * a);
       // 涉及虚数,可不考虑。i ** 2 = -1
     }
 
@@ -1393,8 +1485,16 @@ export default class MathUtil {
 
       if (A > 0 && T < 1 && T > -1) {
         t1 = (-b - 2 * A ** (1 / 2) * Math.cos(theta / 3)) / (3 * a);
-        t2 = (-b + A ** (1 / 2) * (Math.cos(theta / 3) + 3 ** (1 / 2) * Math.sin(theta / 3))) / (3 * a);
-        t3 = (-b + A ** (1 / 2) * (Math.cos(theta / 3) - 3 ** (1 / 2) * Math.sin(theta / 3))) / (3 * a);
+        t2 =
+          (-b +
+            A ** (1 / 2) *
+              (Math.cos(theta / 3) + 3 ** (1 / 2) * Math.sin(theta / 3))) /
+          (3 * a);
+        t3 =
+          (-b +
+            A ** (1 / 2) *
+              (Math.cos(theta / 3) - 3 ** (1 / 2) * Math.sin(theta / 3))) /
+          (3 * a);
       }
     }
     return [t1, t2, t3];
@@ -1415,8 +1515,16 @@ export default class MathUtil {
     const { x: cx1, y: cy1 } = cp1;
     const { x: cx2, y: cy2 } = cp2;
 
-    const x = x1 * (1 - t) * (1 - t) * (1 - t) + 3 * cx1 * t * (1 - t) * (1 - t) + 3 * cx2 * t * t * (1 - t) + x2 * t * t * t;
-    const y = y1 * (1 - t) * (1 - t) * (1 - t) + 3 * cy1 * t * (1 - t) * (1 - t) + 3 * cy2 * t * t * (1 - t) + y2 * t * t * t;
+    const x =
+      x1 * (1 - t) * (1 - t) * (1 - t) +
+      3 * cx1 * t * (1 - t) * (1 - t) +
+      3 * cx2 * t * t * (1 - t) +
+      x2 * t * t * t;
+    const y =
+      y1 * (1 - t) * (1 - t) * (1 - t) +
+      3 * cy1 * t * (1 - t) * (1 - t) +
+      3 * cy2 * t * t * (1 - t) +
+      y2 * t * t * t;
     return { x, y };
   }
 
@@ -1431,8 +1539,16 @@ export default class MathUtil {
     // 参数化方式在曲线上取一系列的点
     var pointsOnCurve = [];
     for (var t = 0; t <= 1; t += 0.01) {
-      var x = Math.pow(1 - t, 3) * p0.x + 3 * Math.pow(1 - t, 2) * t * p1.x + 3 * (1 - t) * Math.pow(t, 2) * p2.x + Math.pow(t, 3) * p3.x;
-      var y = Math.pow(1 - t, 3) * p0.y + 3 * Math.pow(1 - t, 2) * t * p1.y + 3 * (1 - t) * Math.pow(t, 2) * p2.y + Math.pow(t, 3) * p3.y;
+      var x =
+        Math.pow(1 - t, 3) * p0.x +
+        3 * Math.pow(1 - t, 2) * t * p1.x +
+        3 * (1 - t) * Math.pow(t, 2) * p2.x +
+        Math.pow(t, 3) * p3.x;
+      var y =
+        Math.pow(1 - t, 3) * p0.y +
+        3 * Math.pow(1 - t, 2) * t * p1.y +
+        3 * (1 - t) * Math.pow(t, 2) * p2.y +
+        Math.pow(t, 3) * p3.y;
       pointsOnCurve.push({ x: x, y: y });
     }
 
@@ -1440,7 +1556,10 @@ export default class MathUtil {
     var shortestDistance = Number.MAX_VALUE;
     var closestPoint;
     for (var i = 0; i < pointsOnCurve.length; i++) {
-      var distance = Math.sqrt(Math.pow(pointsOnCurve[i].x - target.x, 2) + Math.pow(pointsOnCurve[i].y - target.y, 2));
+      var distance = Math.sqrt(
+        Math.pow(pointsOnCurve[i].x - target.x, 2) +
+          Math.pow(pointsOnCurve[i].y - target.y, 2)
+      );
       if (distance < shortestDistance) {
         shortestDistance = distance;
         closestPoint = pointsOnCurve[i];
@@ -1457,11 +1576,23 @@ export default class MathUtil {
     const { x: offsetX, y: offsetY } = position;
     let results = [];
     // 用 x 求出对应的 t,用 t 求相应位置的 y,再比较得出的 y 与 offsetY 之间的差值
-    const tsx = this.getThreeBezierT(curve.start.x, curve.controls[0].x, curve.controls[1].x, curve.end.x, offsetX);
+    const tsx = this.getThreeBezierT(
+      curve.start.x,
+      curve.controls[0].x,
+      curve.controls[1].x,
+      curve.end.x,
+      offsetX
+    );
     console.log(tsx);
     for (let x = 0; x < 3; x++) {
       if (tsx[x] <= 1 && tsx[x] >= 0) {
-        const point = this.getThreeBezierPoint(tsx[x], curve.start, curve.controls[0], curve.controls[1], curve.end);
+        const point = this.getThreeBezierPoint(
+          tsx[x],
+          curve.start,
+          curve.controls[0],
+          curve.controls[1],
+          curve.end
+        );
         // if (Math.abs(point.y - offsetY) < rang) {
         results.push({
           position: point,
@@ -1471,10 +1602,22 @@ export default class MathUtil {
       }
     }
     // 如果上述没有结果,则用 y 求出对应的 t,再用 t 求出对应的 x,与 offsetX 进行匹配
-    const tsy = this.getThreeBezierT(curve.start.y, curve.controls[0].y, curve.controls[1].y, curve.end.y, offsetY);
+    const tsy = this.getThreeBezierT(
+      curve.start.y,
+      curve.controls[0].y,
+      curve.controls[1].y,
+      curve.end.y,
+      offsetY
+    );
     for (let y = 0; y < 3; y++) {
       if (tsy[y] <= 1 && tsy[y] >= 0) {
-        const point = this.getThreeBezierPoint(tsy[y], curve.start, curve.controls[0], curve.controls[1], curve.end);
+        const point = this.getThreeBezierPoint(
+          tsy[y],
+          curve.start,
+          curve.controls[0],
+          curve.controls[1],
+          curve.end
+        );
         // if (Math.abs(point.x - offsetX) < rang) {
         results.push({
           position: point,
@@ -1515,9 +1658,15 @@ export default class MathUtil {
   getHitInfoForCurves(pos, curves, roadWidth) {
     let joinInfo;
     for (const curve of curves) {
-      const tempJoinInfo = curve.controls.length === 2 ? this.getHitInfoForThreeBezier(pos, curve, roadWidth / 2) : this.getHitInfoForTwoBezier(pos, curve);
-
-      if (!joinInfo || (tempJoinInfo && tempJoinInfo.distance < joinInfo.distance)) {
+      const tempJoinInfo =
+        curve.controls.length === 2
+          ? this.getHitInfoForThreeBezier(pos, curve, roadWidth / 2)
+          : this.getHitInfoForTwoBezier(pos, curve);
+
+      if (
+        !joinInfo ||
+        (tempJoinInfo && tempJoinInfo.distance < joinInfo.distance)
+      ) {
         joinInfo = tempJoinInfo;
       }
     }
@@ -1526,9 +1675,15 @@ export default class MathUtil {
 
   getHitInfoForCurve(pos, curve, roadWidth) {
     let joinInfo;
-    const tempJoinInfo = curve.controls.length === 2 ? this.getHitInfoForThreeBezier(pos, curve, roadWidth / 2) : this.getHitInfoForTwoBezier(pos, curve);
+    const tempJoinInfo =
+      curve.controls.length === 2
+        ? this.getHitInfoForThreeBezier(pos, curve, roadWidth / 2)
+        : this.getHitInfoForTwoBezier(pos, curve);
 
-    if (!joinInfo || (tempJoinInfo && tempJoinInfo.distance < joinInfo.distance)) {
+    if (
+      !joinInfo ||
+      (tempJoinInfo && tempJoinInfo.distance < joinInfo.distance)
+    ) {
       joinInfo = tempJoinInfo;
     }
     return joinInfo;
@@ -1558,7 +1713,10 @@ export default class MathUtil {
       }
     }
     if (index == -1) {
-      if (minDisToPoint > mathUtil.getDistance(position, points[points.length - 1])) {
+      if (
+        minDisToPoint >
+        mathUtil.getDistance(position, points[points.length - 1])
+      ) {
         return points.length;
       } else {
         return minPointIndex;
@@ -1592,7 +1750,10 @@ export default class MathUtil {
       }
     }
     if ((index = -1)) {
-      if (minDisToPoint > mathUtil.getDistance(position, points[points.length - 1])) {
+      if (
+        minDisToPoint >
+        mathUtil.getDistance(position, points[points.length - 1])
+      ) {
         return points.length - 2;
       } else {
         return minPointIndex;
@@ -1645,23 +1806,43 @@ export default class MathUtil {
         if (mathUtil.equalPoint(points[i], points[i + 1])) {
           return null;
         }
-        let leftEdgePoins1 = this.RectangleVertex(points[i], points[i + 1], leftWidth * 2);
-        let leftLine1 = mathUtil.createLine1(leftEdgePoins1.leftEdgeStart, leftEdgePoins1.leftEdgeEnd);
+        let leftEdgePoins1 = this.RectangleVertex(
+          points[i],
+          points[i + 1],
+          leftWidth * 2
+        );
+        let leftLine1 = mathUtil.createLine1(
+          leftEdgePoins1.leftEdgeStart,
+          leftEdgePoins1.leftEdgeEnd
+        );
         if (i != points.length - 2) {
           if (mathUtil.equalPoint(points[i + 2], points[i + 1])) {
             return null;
           }
-          let leftEdgePoins2 = this.RectangleVertex(points[i + 1], points[i + 2], leftWidth * 2);
-
-          let leftLine2 = mathUtil.createLine1(leftEdgePoins2.leftEdgeStart, leftEdgePoins2.leftEdgeEnd);
+          let leftEdgePoins2 = this.RectangleVertex(
+            points[i + 1],
+            points[i + 2],
+            leftWidth * 2
+          );
+
+          let leftLine2 = mathUtil.createLine1(
+            leftEdgePoins2.leftEdgeStart,
+            leftEdgePoins2.leftEdgeEnd
+          );
           let join = mathUtil.getIntersectionPoint(leftLine1, leftLine2);
           if (join != null) {
             leftEdgePoints[i + 1] = join;
           } else {
-            leftEdgePoints[i + 1] = mathUtil.getJoinLinePoint(points[i + 1], leftLine1);
+            leftEdgePoints[i + 1] = mathUtil.getJoinLinePoint(
+              points[i + 1],
+              leftLine1
+            );
           }
         } else {
-          leftEdgePoints[i + 1] = mathUtil.getJoinLinePoint(points[i + 1], leftLine1);
+          leftEdgePoints[i + 1] = mathUtil.getJoinLinePoint(
+            points[i + 1],
+            leftLine1
+          );
         }
         if (!leftEdgePoints[0]) {
           leftEdgePoints[0] = mathUtil.getJoinLinePoint(points[0], leftLine1);
@@ -1672,23 +1853,43 @@ export default class MathUtil {
         if (mathUtil.equalPoint(points[i], points[i + 1])) {
           return null;
         }
-        let rightEdgePoins1 = this.RectangleVertex(points[i], points[i + 1], rightWidth * 2);
-        let rightLine1 = mathUtil.createLine1(rightEdgePoins1.rightEdgeStart, rightEdgePoins1.rightEdgeEnd);
+        let rightEdgePoins1 = this.RectangleVertex(
+          points[i],
+          points[i + 1],
+          rightWidth * 2
+        );
+        let rightLine1 = mathUtil.createLine1(
+          rightEdgePoins1.rightEdgeStart,
+          rightEdgePoins1.rightEdgeEnd
+        );
         if (i != points.length - 2) {
           if (mathUtil.equalPoint(points[i + 2], points[i + 1])) {
             return null;
           }
-          let rightEdgePoins2 = this.RectangleVertex(points[i + 1], points[i + 2], rightWidth * 2);
-
-          let rightLine2 = mathUtil.createLine1(rightEdgePoins2.rightEdgeStart, rightEdgePoins2.rightEdgeEnd);
+          let rightEdgePoins2 = this.RectangleVertex(
+            points[i + 1],
+            points[i + 2],
+            rightWidth * 2
+          );
+
+          let rightLine2 = mathUtil.createLine1(
+            rightEdgePoins2.rightEdgeStart,
+            rightEdgePoins2.rightEdgeEnd
+          );
           let join = mathUtil.getIntersectionPoint(rightLine1, rightLine2);
           if (join != null) {
             rightEdgePoints[i + 1] = join;
           } else {
-            rightEdgePoints[i + 1] = mathUtil.getJoinLinePoint(points[i + 1], rightLine1);
+            rightEdgePoints[i + 1] = mathUtil.getJoinLinePoint(
+              points[i + 1],
+              rightLine1
+            );
           }
         } else {
-          rightEdgePoints[i + 1] = mathUtil.getJoinLinePoint(points[i + 1], rightLine1);
+          rightEdgePoints[i + 1] = mathUtil.getJoinLinePoint(
+            points[i + 1],
+            rightLine1
+          );
         }
 
         if (!rightEdgePoints[0]) {
@@ -1774,7 +1975,6 @@ export default class MathUtil {
     };
     return targetPoint;
   }
-
 }
 
 const mathUtil = new MathUtil();