|
@@ -66,39 +66,41 @@ export default class Circle extends Geometry {
|
|
|
this.setRadiusX(distance);
|
|
|
distance = this.radiusY;
|
|
|
}
|
|
|
- const lines = mathUtil.getParallelLineForDistance(line, distance);
|
|
|
- const vLine = mathUtil.getVerticalLine(line, this.center);
|
|
|
- const join1 = mathUtil.getIntersectionPoint(lines.line1, vLine);
|
|
|
- const join2 = mathUtil.getIntersectionPoint(lines.line2, vLine);
|
|
|
- //顺时针
|
|
|
- if (
|
|
|
- !mathUtil.isClockwise([
|
|
|
- this.points[index],
|
|
|
- join1,
|
|
|
- this.points[oppositeIndex],
|
|
|
- ])
|
|
|
- ) {
|
|
|
- let nextIndex = this.getNext(index);
|
|
|
- this.points[nextIndex] = {
|
|
|
- x: join1.x,
|
|
|
- y: join1.y,
|
|
|
- };
|
|
|
- nextIndex = this.getOpposite(nextIndex);
|
|
|
- this.points[nextIndex] = {
|
|
|
- x: join2.x,
|
|
|
- y: join2.y,
|
|
|
- };
|
|
|
- } else {
|
|
|
- let nextIndex = this.getNext(index);
|
|
|
- this.points[nextIndex] = {
|
|
|
- x: join2.x,
|
|
|
- y: join2.y,
|
|
|
- };
|
|
|
- nextIndex = this.getOpposite(nextIndex);
|
|
|
- this.points[nextIndex] = {
|
|
|
- x: join1.x,
|
|
|
- y: join1.y,
|
|
|
- };
|
|
|
+ if (line) {
|
|
|
+ const lines = mathUtil.getParallelLineForDistance(line, distance);
|
|
|
+ const vLine = mathUtil.getVerticalLine(line, this.center);
|
|
|
+ const join1 = mathUtil.getIntersectionPoint(lines.line1, vLine);
|
|
|
+ const join2 = mathUtil.getIntersectionPoint(lines.line2, vLine);
|
|
|
+ //顺时针
|
|
|
+ if (
|
|
|
+ !mathUtil.isClockwise([
|
|
|
+ this.points[index],
|
|
|
+ join1,
|
|
|
+ this.points[oppositeIndex],
|
|
|
+ ])
|
|
|
+ ) {
|
|
|
+ let nextIndex = this.getNext(index);
|
|
|
+ this.points[nextIndex] = {
|
|
|
+ x: join1.x,
|
|
|
+ y: join1.y,
|
|
|
+ };
|
|
|
+ nextIndex = this.getOpposite(nextIndex);
|
|
|
+ this.points[nextIndex] = {
|
|
|
+ x: join2.x,
|
|
|
+ y: join2.y,
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ let nextIndex = this.getNext(index);
|
|
|
+ this.points[nextIndex] = {
|
|
|
+ x: join2.x,
|
|
|
+ y: join2.y,
|
|
|
+ };
|
|
|
+ nextIndex = this.getOpposite(nextIndex);
|
|
|
+ this.points[nextIndex] = {
|
|
|
+ x: join1.x,
|
|
|
+ y: join1.y,
|
|
|
+ };
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|