Flue.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import VectorType from '../enum/VectorType.js'
  2. import SelectState from '../enum/SelectState.js'
  3. import Geometry from './Geometry'
  4. import { mathUtil } from '../MathUtil.js'
  5. import Constant from '../Constant.js'
  6. import { coordinate } from '../Coordinate'
  7. //不靠墙
  8. export default class Flue extends Geometry {
  9. constructor(center, vectorId) {
  10. super()
  11. this.center = center
  12. this.angle = 0 //逆时针为正,顺时针为负。单位是:°
  13. this.points2d = []
  14. this.sideWidth = 0.65
  15. this.sideThickness = 0.65
  16. this.name = '烟道'
  17. this.geoType = VectorType.Flue
  18. this.setId(vectorId)
  19. }
  20. isContain(position) {
  21. let points = []
  22. points.push(this.points2d[0])
  23. points.push(this.points2d[1])
  24. points.push(this.points2d[2])
  25. points.push(this.points2d[3])
  26. return mathUtil.isPointInPoly(position, points)
  27. }
  28. setPoints2d() {
  29. this.points2d = []
  30. let minX = this.center.x - this.sideWidth / 2
  31. let minY = this.center.y - this.sideThickness / 2
  32. let maxX = this.center.x + this.sideWidth / 2
  33. let maxY = this.center.y + this.sideThickness / 2
  34. const point1 = this.rotatePoint(
  35. {
  36. x: minX,
  37. y: maxY,
  38. },
  39. this.center,
  40. this.angle
  41. )
  42. const point2 = this.rotatePoint(
  43. {
  44. x: maxX,
  45. y: maxY,
  46. },
  47. this.center,
  48. this.angle
  49. )
  50. const point3 = this.rotatePoint(
  51. {
  52. x: maxX,
  53. y: minY,
  54. },
  55. this.center,
  56. this.angle
  57. )
  58. const point4 = this.rotatePoint(
  59. {
  60. x: minX,
  61. y: minY,
  62. },
  63. this.center,
  64. this.angle
  65. )
  66. this.points2d.push(point1)
  67. this.points2d.push(point2)
  68. this.points2d.push(point3)
  69. this.points2d.push(point4)
  70. minX = this.center.x - (this.sideWidth - 0.1) / 2
  71. minY = this.center.y - (this.sideThickness - 0.1) / 2
  72. maxX = this.center.x + (this.sideWidth - 0.1) / 2
  73. maxY = this.center.y + (this.sideThickness - 0.1) / 2
  74. const point5 = this.rotatePoint(
  75. {
  76. x: minX,
  77. y: maxY,
  78. },
  79. this.center,
  80. this.angle
  81. )
  82. const point6 = this.rotatePoint(
  83. {
  84. x: maxX,
  85. y: maxY,
  86. },
  87. this.center,
  88. this.angle
  89. )
  90. const point7 = this.rotatePoint(
  91. {
  92. x: maxX,
  93. y: minY,
  94. },
  95. this.center,
  96. this.angle
  97. )
  98. const point8 = this.rotatePoint(
  99. {
  100. x: minX,
  101. y: minY,
  102. },
  103. this.center,
  104. this.angle
  105. )
  106. const point9 = {
  107. x: (this.center.x + point6.x) / 2,
  108. y: (this.center.y + point6.y) / 2,
  109. }
  110. this.points2d.push(point5)
  111. this.points2d.push(point6)
  112. this.points2d.push(point7)
  113. this.points2d.push(point8)
  114. this.points2d.push(point9)
  115. }
  116. }