12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import { dataService } from "../Service/DataService";
- // import { mathUtil } from "../Util/MathUtil.js/index.js";
- import SymbolEvents from "../enum/SymbolEvents.js";
- export default class Geometry {
- constructor() {
- this.len = null;
- }
- setId(vectorId) {
- if (vectorId == null || typeof vectorId === "undefined") {
- vectorId = dataService.getCurrentId();
- dataService.updateCurrentId();
- this.vectorId = this.geoType + vectorId;
- } else {
- this.vectorId = vectorId;
- }
- }
- setPointParent(parentId, dir) {
- if (this.parent == null) {
- this.parent = {};
- }
- this.parent[parentId] = dir;
- }
- setLeftEdge(edgeId) {
- this.leftEdgeId = edgeId;
- }
- setRightEdge(edgeId) {
- this.rightEdgeId = edgeId;
- }
- getParent() {
- return this.parent;
- }
- // 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;
- }
- }
|