1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- import { dataService } from "../Service/DataService";
- import Settings from "../Settings";
- export default class MovePoint {
- constructor() {}
- movePoint(position, pointId) {
- let point = dataService.getPoint(pointId);
- point.x = position.x;
- point.y = position.y;
- }
- //直角定位法
- //movePointForLocationByAngle(testPointId, basePointId) {
- movePointByAngleLocation(pointId) {
- if (testPointId == null || basePointId == null) {
- return null;
- }
- let testPoint = dataService.getPoint(testPointId);
- let basePoint = dataService.getPoint(basePointId);
- let lineGeometry = dataService.getLine(Settings.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.create(join);
- lineService.createByPointId(
- testPointId,
- join.vectorId,
- VectorCategory.Line.PositionLine
- );
- lineService.createByPointId(
- basePointId,
- join.vectorId,
- VectorCategory.Line.PositionLine
- );
- }
- //综合定位法
- movePointForLocationByFull(testPointId1, testPointId2, basePointId) {
- if (testPointId1 == null || basePointId == null) {
- return null;
- } else {
- let testPoint1 = dataService.getPoint(testPointId1);
- let lineGeometry = dataService.getLine(Settings.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.create(join);
- 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.create(join);
- lineService.createByPointId(
- testPointId2,
- join.vectorId,
- VectorCategory.Line.PositionLine
- );
- lineService.createByPointId(
- testPointId2,
- testPointId1,
- VectorCategory.Line.PositionLine
- );
- }
- }
- }
- }
- const movePoint = new MovePoint();
- export { movePoint };
|