MovePoint.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { dataService } from "../Service/DataService";
  2. export default class MovePoint {
  3. constructor() {}
  4. movePoint(position, pointId) {
  5. let point = dataService.getPoint(pointId);
  6. point.x = position.x;
  7. point.y = position.y;
  8. }
  9. //直角定位法
  10. //movePointForLocationByAngle(testPointId, basePointId) {
  11. movePointByAngleLocation(pointId) {
  12. if (testPointId == null || basePointId == null) {
  13. return null;
  14. }
  15. let testPoint = dataService.getPoint(testPointId);
  16. let basePoint = dataService.getPoint(basePointId);
  17. let lineGeometry = dataService.getLine(addLine.baseLineId);
  18. let startPoint = dataService.getPoint(lineGeometry.startId);
  19. let endPoint = dataService.getPoint(lineGeometry.endId);
  20. let line = mathUtil.createLine1(startPoint, endPoint);
  21. let vLine1 = mathUtil.getVerticalLine(line, testPoint);
  22. let join = mathUtil.getJoinLinePoint(basePoint, vLine1);
  23. join = pointService.create(join);
  24. lineService.createByPointId(
  25. testPointId,
  26. join.vectorId,
  27. VectorCategory.Line.PositionLine
  28. );
  29. lineService.createByPointId(
  30. basePointId,
  31. join.vectorId,
  32. VectorCategory.Line.PositionLine
  33. );
  34. }
  35. //综合定位法
  36. movePointForLocationByFull(testPointId1, testPointId2, basePointId) {
  37. if (testPointId1 == null || basePointId == null) {
  38. return null;
  39. } else {
  40. let testPoint1 = dataService.getPoint(testPointId1);
  41. let lineGeometry = dataService.getLine(addLine.baseLineId);
  42. let startPoint = dataService.getPoint(lineGeometry.startId);
  43. let endPoint = dataService.getPoint(lineGeometry.endId);
  44. let line = mathUtil.createLine1(startPoint, endPoint);
  45. if (testPointId2 == null) {
  46. let join = mathUtil.getJoinLinePoint(testPoint1, line);
  47. join = pointService.create(join);
  48. lineService.createByPointId(
  49. testPointId1,
  50. join.vectorId,
  51. VectorCategory.Line.PositionLine
  52. );
  53. lineService.createByPointId(
  54. basePointId,
  55. testPointId1,
  56. VectorCategory.Line.PositionLine
  57. );
  58. } else {
  59. let testPoint2 = dataService.getPoint(testPointId2);
  60. let join = mathUtil.getJoinLinePoint(testPoint2, line);
  61. join = pointService.create(join);
  62. lineService.createByPointId(
  63. testPointId2,
  64. join.vectorId,
  65. VectorCategory.Line.PositionLine
  66. );
  67. lineService.createByPointId(
  68. testPointId2,
  69. testPointId1,
  70. VectorCategory.Line.PositionLine
  71. );
  72. }
  73. }
  74. }
  75. }
  76. const movePoint = new MovePoint();
  77. export { movePoint };