|
@@ -0,0 +1,85 @@
|
|
|
+import { dataService } from "../Service/DataService";
|
|
|
+import { lineService } from "../Service/LineService";
|
|
|
+import { pointService } from "../Service/PointService";
|
|
|
+import VectorCategory from "../enum/VectorCategory";
|
|
|
+import Point from "../Geometry/Point.js";
|
|
|
+import { mathUtil } from "../Util/MathUtil";
|
|
|
+import addLine from "./AddLine";
|
|
|
+
|
|
|
+export default class AddPoint {
|
|
|
+ constructor() {}
|
|
|
+
|
|
|
+ //直角定位法
|
|
|
+ setLocationByAngle(testPointId, basePointId) {
|
|
|
+ if (testPointId == null || basePointId == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ let testPoint = dataService.getPoint(testPointId);
|
|
|
+ let basePoint = dataService.getPoint(basePointId);
|
|
|
+ let lineGeometry = dataService.getLine(addLine.baseLineId);
|
|
|
+ let startPoint = dataService.getPoint(lineGeometry.startId);
|
|
|
+ let endPoint = dataService.getPoint(lineGeometry.endId);
|
|
|
+ let line = mathUtil.createLine1(startPoint, endPoint);
|
|
|
+ let vLine1 = mathUtil.getVerticalLine(line, testPoint);
|
|
|
+ let join = mathUtil.getJoinLinePoint(basePoint, vLine1);
|
|
|
+ join = pointService.addPoint(join, VectorCategory.Point.TestBasePoint);
|
|
|
+
|
|
|
+ lineService.createByPointId(
|
|
|
+ testPointId,
|
|
|
+ join.vectorId,
|
|
|
+ VectorCategory.Line.PositionLine
|
|
|
+ );
|
|
|
+
|
|
|
+ lineService.createByPointId(
|
|
|
+ basePointId,
|
|
|
+ join.vectorId,
|
|
|
+ VectorCategory.Line.PositionLine
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ //综合定位法
|
|
|
+ setLocationByFull(testPointId1, testPointId2, basePointId) {
|
|
|
+ if (testPointId1 == null || basePointId == null) {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ let testPoint1 = dataService.getPoint(testPointId1);
|
|
|
+ let lineGeometry = dataService.getLine(addLine.baseLineId);
|
|
|
+ let startPoint = dataService.getPoint(lineGeometry.startId);
|
|
|
+ let endPoint = dataService.getPoint(lineGeometry.endId);
|
|
|
+ let line = mathUtil.createLine1(startPoint, endPoint);
|
|
|
+ if (testPointId2 == null) {
|
|
|
+ let join = mathUtil.getJoinLinePoint(testPoint1, line);
|
|
|
+ join = pointService.addPoint(join, VectorCategory.Point.TestBasePoint);
|
|
|
+ lineService.createByPointId(
|
|
|
+ testPointId1,
|
|
|
+ join.vectorId,
|
|
|
+ VectorCategory.Line.PositionLine
|
|
|
+ );
|
|
|
+
|
|
|
+ lineService.createByPointId(
|
|
|
+ basePointId,
|
|
|
+ testPointId1,
|
|
|
+ VectorCategory.Line.PositionLine
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ let testPoint2 = dataService.getPoint(testPointId2);
|
|
|
+ let join = mathUtil.getJoinLinePoint(testPoint2, line);
|
|
|
+ join = pointService.addPoint(join, VectorCategory.Point.TestBasePoint);
|
|
|
+ lineService.createByPointId(
|
|
|
+ testPointId2,
|
|
|
+ join.vectorId,
|
|
|
+ VectorCategory.Line.PositionLine
|
|
|
+ );
|
|
|
+
|
|
|
+ lineService.createByPointId(
|
|
|
+ testPointId2,
|
|
|
+ testPointId1,
|
|
|
+ VectorCategory.Line.PositionLine
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const addPoint = new AddPoint();
|
|
|
+export { addPoint };
|