MovePoint.js 2.6 KB

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