|
@@ -1,26 +1,50 @@
|
|
|
import VectorType from '../enum/VectorType.js'
|
|
|
import Geometry from './Geometry.js'
|
|
|
+import SelectState from '../enum/SelectState.js'
|
|
|
|
|
|
export default class Circle extends Geometry {
|
|
|
constructor(position,radius, vectorId, floor) {
|
|
|
super()
|
|
|
- this.position = position
|
|
|
+ this.center = position
|
|
|
this.radius = radius
|
|
|
+ this.points = []; //顺时针
|
|
|
this.floor = floor?floor:0
|
|
|
this.geoType = VectorType.Circle
|
|
|
this.setId(vectorId)
|
|
|
}
|
|
|
|
|
|
- isContain(position){
|
|
|
- const dis = mathUtil.getDistance(position, this.position)
|
|
|
- if(Math.abs(this.radius - dis)<Constant.minAdsorb){
|
|
|
- return 'side'
|
|
|
+ setPoints(){
|
|
|
+ this.points[0] = {
|
|
|
+ x:this.center - this.radius/2,
|
|
|
+ y:this.center + this.radius/2
|
|
|
+ }
|
|
|
+ this.points[1] = {
|
|
|
+ x:this.center + this.radius/2,
|
|
|
+ y:this.center + this.radius/2
|
|
|
}
|
|
|
- else if((dis-this.radius)>Constant.minAdsorb){
|
|
|
- return null;
|
|
|
+ this.points[2] = {
|
|
|
+ x:this.center + this.radius/2,
|
|
|
+ y:this.center - this.radius/2
|
|
|
}
|
|
|
- else if((this.radius - dis)>Constant.minAdsorb){
|
|
|
- return 'all'
|
|
|
+ this.points[3] = {
|
|
|
+ x:this.center - this.radius/2,
|
|
|
+ y:this.center - this.radius/2
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ isContain(position){
|
|
|
+ for(let i=0;i<this.points.length;++i){
|
|
|
+ const dis = mathUtil.getDistance(position, this.points[i])
|
|
|
+ if(dis < Constant.minAdsorb){
|
|
|
+ return SelectState.Scale
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const dis = mathUtil.getDistance(position, this.center)
|
|
|
+ if(Math.abs(this.radius - dis)<Constant.minAdsorb){
|
|
|
+ return SelectState.All
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|