import VectorType from '../enum/VectorType.js' import SelectState from '../enum/SelectState.js' import Geometry from './Geometry' import { mathUtil } from '../MathUtil.js' import Constant from '../Constant.js' import { coordinate } from '../Coordinate' //靠墙 export default class Beam extends Geometry { constructor(center, vectorId) { super() this.center = center this.angle = 0 //逆时针为负,顺时针为正。单位是:° this.points2d = [] this.sideWidth = 0.65 this.sideThickness = 0.65 this.name = '柱子' this.geoType = VectorType.Beam this.setId(vectorId) } isContain(position) { return mathUtil.isPointInPoly(position, this.points2d) } setPoints2d() { this.points2d = [] const minX = this.center.x - this.sideWidth / 2 const minY = this.center.y - this.sideThickness / 2 const maxX = this.center.x + this.sideWidth / 2 const maxY = this.center.y + this.sideThickness / 2 const point1 = this.rotatePoint( { x: minX, y: maxY, }, this.center, this.angle ) const point2 = this.rotatePoint( { x: maxX, y: maxY, }, this.center, this.angle ) const point3 = this.rotatePoint( { x: maxX, y: minY, }, this.center, this.angle ) const point4 = this.rotatePoint( { x: minX, y: minY, }, this.center, this.angle ) this.points2d.push(point1) this.points2d.push(point2) this.points2d.push(point3) this.points2d.push(point4) } }