1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import VectorType from '../enum/VectorType.js'
- import Geometry from './Geometry'
- import { coordinate } from '../Coordinate'
- import { mathUtil } from '../MathUtil.js'
- export default class Compass extends Geometry {
- constructor(angle,vectorId, floor) {
- super()
- this.angle = angle?angle:0
- this.floor = floor?floor:0
- //固定位置
- this.center = {
- x:880,
- y:120
- }
- this.radius = 52 //svg的大小
- this.geoType = VectorType.Compass
- this.setId(vectorId)
- }
- setAngle(angle){
- this.angle = angle
- }
- //center是左上角,宽是56,高是36
- isContain(position) {
- const point = coordinate.getScreenXY(position)
- // const dis = mathUtil.getDistance(this.center,point)
- // if(dis < this.radius){
- // return true
- // }
- // else{
- // return false;
- // }
- //console.log('xy:'+(point.x - this.center.x)+','+(point.y - this.center.y))
- if(point.x - this.center.x > -5 && point.x - this.center.x < 40 && point.y - this.center.y > -5 && point.y - this.center.y < 60){
- return true
- }else{
- return false;
- }
- }
- }
|