import { floorplanService } from '../Service/FloorplanService'
import { mathUtil } from '../MathUtil.js'

export default class Geometry {
    constructor() {
        this.len = null
        this.version = 2;
    }

    setId(vectorId) {
        if (vectorId == null || typeof vectorId === 'undefined') {
            vectorId = floorplanService.getCurrentId()
            floorplanService.updateCurrentId()
            this.vectorId = this.geoType + vectorId
        } else {
            this.vectorId = vectorId
        }
    }

    setPointParent(wallId, dir) {
        if (this.parent == null) {
            this.parent = {}
        }

        this.parent[wallId] = dir
    }

    // ptSrc: 圆上某点(初始点);
    // ptRotationCenter: 圆心点;
    // angle: 旋转角度°  -- [angle * M_PI / 180]:将角度换算为弧度
    // 【注意】angle 逆时针为正，顺时针为负
    rotatePoint(ptSrc, ptRotationCenter, angle) {
        angle = -1 * angle //设计是逆时针为负，顺时针为正
        var a = ptRotationCenter.x
        var b = ptRotationCenter.y
        var x0 = ptSrc.x
        var y0 = ptSrc.y
        var rx = a + (x0 - a) * Math.cos((angle * Math.PI) / 180) - (y0 - b) * Math.sin((angle * Math.PI) / 180)
        var ry = b + (x0 - a) * Math.sin((angle * Math.PI) / 180) + (y0 - b) * Math.cos((angle * Math.PI) / 180)
        var json = { x: rx, y: ry }
        return json
    }
}
