geometric-library 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -430
- package/dist/cjs/abstracts/{Angle.js → angle/Angle.js} +11 -11
- package/dist/cjs/abstracts/angle/Angle.types.js +2 -0
- package/dist/cjs/abstracts/angle/index.js +18 -0
- package/dist/cjs/abstracts/{Figure.js → figure/Figure.js} +45 -30
- package/dist/cjs/abstracts/figure/Figure.types.js +2 -0
- package/dist/cjs/abstracts/figure/index.js +18 -0
- package/dist/cjs/abstracts/{Flag.js → flag/Flag.js} +1 -0
- package/dist/cjs/abstracts/flag/Flag.types.js +2 -0
- package/dist/cjs/abstracts/flag/index.js +18 -0
- package/dist/cjs/abstracts/index.js +22 -0
- package/dist/cjs/abstracts/{Magnitude.js → magnitude/Magnitude.js} +3 -2
- package/dist/cjs/abstracts/magnitude/Magnitude.types.js +2 -0
- package/dist/cjs/abstracts/magnitude/index.js +18 -0
- package/dist/cjs/abstracts/{Point.js → point/Point.js} +8 -7
- package/dist/cjs/abstracts/point/Point.types.js +2 -0
- package/dist/cjs/abstracts/point/index.js +18 -0
- package/dist/cjs/abstracts/{Vector.js → vector/Vector.js} +16 -15
- package/dist/cjs/abstracts/vector/Vector.types.js +2 -0
- package/dist/cjs/abstracts/vector/index.js +18 -0
- package/dist/cjs/figures/arc-curve/ArcCurve.js +174 -0
- package/dist/cjs/figures/arc-curve/ArcCurve.types.js +2 -0
- package/dist/cjs/figures/arc-curve/index.js +18 -0
- package/dist/cjs/figures/{Circle.js → circle/Circle.js} +8 -9
- package/dist/cjs/figures/circle/Circle.types.js +2 -0
- package/dist/cjs/figures/circle/index.js +18 -0
- package/dist/cjs/figures/{CubicBezierCurve.js → cubic-bezier-curve/CubicBezierCurve.js} +22 -17
- package/dist/cjs/figures/cubic-bezier-curve/CubicBezierCurve.types.js +2 -0
- package/dist/cjs/figures/cubic-bezier-curve/index.js +18 -0
- package/dist/cjs/figures/ellipse/Ellipse.js +129 -0
- package/dist/cjs/figures/ellipse/Ellipse.types.js +2 -0
- package/dist/cjs/figures/ellipse/index.js +18 -0
- package/dist/cjs/figures/index.js +23 -0
- package/dist/cjs/figures/{Line.js → line/Line.js} +78 -59
- package/dist/cjs/figures/line/Line.types.js +2 -0
- package/dist/cjs/figures/line/index.js +18 -0
- package/dist/cjs/figures/polygon/Polygon.js +51 -0
- package/dist/cjs/figures/polygon/Polygon.types.js +2 -0
- package/dist/cjs/figures/polygon/index.js +18 -0
- package/dist/cjs/figures/{QuadraticBezierCurve.js → quadratic-bezier-curve/QuadraticBezierCurve.js} +12 -8
- package/dist/cjs/figures/quadratic-bezier-curve/QuadraticBezierCurve.types.js +2 -0
- package/dist/cjs/figures/quadratic-bezier-curve/index.js +18 -0
- package/dist/cjs/index.js +2 -29
- package/dist/cjs/utilities/{Calculator.js → calculator/Calculator.js} +9 -1
- package/dist/cjs/utilities/calculator/index.js +17 -0
- package/dist/cjs/utilities/index.js +20 -8
- package/dist/esm/abstracts/{Angle.js → angle/Angle.js} +4 -4
- package/dist/esm/abstracts/angle/Angle.types.js +1 -0
- package/dist/esm/abstracts/angle/index.js +2 -0
- package/dist/esm/abstracts/{Figure.js → figure/Figure.js} +37 -22
- package/dist/esm/abstracts/figure/Figure.types.js +1 -0
- package/dist/esm/abstracts/figure/index.js +2 -0
- package/dist/esm/abstracts/{Flag.js → flag/Flag.js} +1 -0
- package/dist/esm/abstracts/flag/Flag.types.js +1 -0
- package/dist/esm/abstracts/flag/index.js +2 -0
- package/dist/esm/abstracts/index.js +6 -0
- package/dist/esm/abstracts/{Magnitude.js → magnitude/Magnitude.js} +2 -1
- package/dist/esm/abstracts/magnitude/Magnitude.types.js +1 -0
- package/dist/esm/abstracts/magnitude/index.js +2 -0
- package/dist/esm/abstracts/{Point.js → point/Point.js} +2 -1
- package/dist/esm/abstracts/point/Point.types.js +1 -0
- package/dist/esm/abstracts/point/index.js +2 -0
- package/dist/esm/abstracts/{Vector.js → vector/Vector.js} +3 -2
- package/dist/esm/abstracts/vector/Vector.types.js +1 -0
- package/dist/esm/abstracts/vector/index.js +2 -0
- package/dist/esm/figures/{ArcCurve.js → arc-curve/ArcCurve.js} +50 -8
- package/dist/esm/figures/arc-curve/ArcCurve.types.js +1 -0
- package/dist/esm/figures/arc-curve/index.js +2 -0
- package/dist/esm/figures/{Circle.js → circle/Circle.js} +3 -4
- package/dist/esm/figures/circle/Circle.types.js +1 -0
- package/dist/esm/figures/circle/index.js +2 -0
- package/dist/esm/figures/{CubicBezierCurve.js → cubic-bezier-curve/CubicBezierCurve.js} +11 -6
- package/dist/esm/figures/cubic-bezier-curve/CubicBezierCurve.types.js +1 -0
- package/dist/esm/figures/cubic-bezier-curve/index.js +2 -0
- package/dist/esm/figures/{Ellipse.js → ellipse/Ellipse.js} +24 -6
- package/dist/esm/figures/ellipse/Ellipse.types.js +1 -0
- package/dist/esm/figures/ellipse/index.js +2 -0
- package/dist/esm/figures/index.js +7 -0
- package/dist/esm/figures/{Line.js → line/Line.js} +57 -38
- package/dist/esm/figures/line/Line.types.js +1 -0
- package/dist/esm/figures/line/index.js +2 -0
- package/dist/esm/figures/polygon/Polygon.js +47 -0
- package/dist/esm/figures/polygon/Polygon.types.js +1 -0
- package/dist/esm/figures/polygon/index.js +2 -0
- package/dist/esm/figures/{QuadraticBezierCurve.js → quadratic-bezier-curve/QuadraticBezierCurve.js} +7 -3
- package/dist/esm/figures/quadratic-bezier-curve/QuadraticBezierCurve.types.js +1 -0
- package/dist/esm/figures/quadratic-bezier-curve/index.js +2 -0
- package/dist/esm/index.js +2 -14
- package/dist/esm/utilities/{Calculator.js → calculator/Calculator.js} +9 -1
- package/dist/esm/utilities/calculator/index.js +1 -0
- package/dist/esm/utilities/index.js +4 -6
- package/dist/types/abstracts/{Angle.d.ts → angle/Angle.d.ts} +2 -1
- package/dist/types/abstracts/angle/Angle.types.d.ts +16 -0
- package/dist/types/abstracts/angle/index.d.ts +2 -0
- package/dist/types/abstracts/{Figure.d.ts → figure/Figure.d.ts} +4 -4
- package/dist/types/abstracts/figure/Figure.types.d.ts +14 -0
- package/dist/types/abstracts/figure/index.d.ts +2 -0
- package/dist/types/abstracts/{Flag.d.ts → flag/Flag.d.ts} +2 -1
- package/dist/types/abstracts/flag/Flag.types.d.ts +8 -0
- package/dist/types/abstracts/flag/index.d.ts +2 -0
- package/dist/types/abstracts/index.d.ts +6 -0
- package/dist/types/abstracts/{Magnitude.d.ts → magnitude/Magnitude.d.ts} +2 -1
- package/dist/types/abstracts/magnitude/Magnitude.types.d.ts +8 -0
- package/dist/types/abstracts/magnitude/index.d.ts +2 -0
- package/dist/types/abstracts/{Point.d.ts → point/Point.d.ts} +2 -1
- package/dist/types/abstracts/point/Point.types.d.ts +13 -0
- package/dist/types/abstracts/point/index.d.ts +2 -0
- package/dist/types/abstracts/{Vector.d.ts → vector/Vector.d.ts} +3 -1
- package/dist/types/abstracts/vector/Vector.types.d.ts +19 -0
- package/dist/types/abstracts/vector/index.d.ts +2 -0
- package/dist/types/figures/{ArcCurve.d.ts → arc-curve/ArcCurve.d.ts} +7 -2
- package/dist/types/figures/arc-curve/ArcCurve.types.d.ts +11 -0
- package/dist/types/figures/arc-curve/index.d.ts +2 -0
- package/dist/types/figures/{Circle.d.ts → circle/Circle.d.ts} +3 -2
- package/dist/types/figures/circle/Circle.types.d.ts +9 -0
- package/dist/types/figures/circle/index.d.ts +2 -0
- package/dist/types/figures/{CubicBezierCurve.d.ts → cubic-bezier-curve/CubicBezierCurve.d.ts} +4 -2
- package/dist/types/figures/cubic-bezier-curve/CubicBezierCurve.types.d.ts +8 -0
- package/dist/types/figures/cubic-bezier-curve/index.d.ts +2 -0
- package/dist/types/figures/{Ellipse.d.ts → ellipse/Ellipse.d.ts} +5 -2
- package/dist/types/figures/ellipse/Ellipse.types.d.ts +16 -0
- package/dist/types/figures/ellipse/index.d.ts +2 -0
- package/dist/types/figures/index.d.ts +7 -0
- package/dist/types/figures/{Line.d.ts → line/Line.d.ts} +6 -4
- package/dist/types/figures/line/Line.types.d.ts +30 -0
- package/dist/types/figures/line/index.d.ts +2 -0
- package/dist/types/figures/polygon/Polygon.d.ts +17 -0
- package/dist/types/figures/polygon/Polygon.types.d.ts +8 -0
- package/dist/types/figures/polygon/index.d.ts +2 -0
- package/dist/types/figures/{QuadraticBezierCurve.d.ts → quadratic-bezier-curve/QuadraticBezierCurve.d.ts} +4 -2
- package/dist/types/figures/quadratic-bezier-curve/QuadraticBezierCurve.types.d.ts +8 -0
- package/dist/types/figures/quadratic-bezier-curve/index.d.ts +2 -0
- package/dist/types/index.d.ts +2 -14
- package/dist/types/types/index.d.ts +0 -129
- package/dist/types/utilities/{Calculator.d.ts → calculator/Calculator.d.ts} +4 -0
- package/dist/types/utilities/calculator/index.d.ts +1 -0
- package/dist/types/utilities/index.d.ts +2 -4
- package/package.json +24 -18
- package/dist/cjs/figures/ArcCurve.js +0 -132
- package/dist/cjs/figures/Ellipse.js +0 -111
- package/dist/cjs/figures/Polygon.js +0 -17
- package/dist/esm/figures/Polygon.js +0 -13
- package/dist/types/figures/Polygon.d.ts +0 -7
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ArcCurve = void 0;
|
|
4
|
-
const Calculator_1 = require("../utilities/Calculator");
|
|
5
|
-
const Point_1 = require("../abstracts/Point");
|
|
6
|
-
const Figure_1 = require("../abstracts/Figure");
|
|
7
|
-
const Ellipse_1 = require("./Ellipse");
|
|
8
|
-
class ArcCurve extends Figure_1.Figure {
|
|
9
|
-
ellipse;
|
|
10
|
-
largeArcFlag;
|
|
11
|
-
phi;
|
|
12
|
-
rx;
|
|
13
|
-
ry;
|
|
14
|
-
sweepFlag;
|
|
15
|
-
constructor(values) {
|
|
16
|
-
super(values);
|
|
17
|
-
const [, rx, ry, phi, largeArcFlag, sweepFlag] = values;
|
|
18
|
-
this.rx = rx;
|
|
19
|
-
this.ry = ry;
|
|
20
|
-
this.phi = phi;
|
|
21
|
-
this.largeArcFlag = largeArcFlag;
|
|
22
|
-
this.sweepFlag = sweepFlag;
|
|
23
|
-
this.adjustRadii();
|
|
24
|
-
const center = this.computeCenter();
|
|
25
|
-
this.ellipse = new Ellipse_1.Ellipse([center, rx, ry, phi]);
|
|
26
|
-
}
|
|
27
|
-
get boundingBox() {
|
|
28
|
-
const { P0, P1 } = this;
|
|
29
|
-
const points = [P0, P1, ...this.criticalPoints];
|
|
30
|
-
return Figure_1.Figure.computeBoundingBox(points);
|
|
31
|
-
}
|
|
32
|
-
get center() {
|
|
33
|
-
return this.ellipse.center;
|
|
34
|
-
}
|
|
35
|
-
get criticalPoints() {
|
|
36
|
-
const { ellipse } = this;
|
|
37
|
-
const [minTheta, maxTheta] = this.computeThetaRange();
|
|
38
|
-
return ellipse.criticalPoints.filter((point) => {
|
|
39
|
-
const { P0, P1 } = this;
|
|
40
|
-
if ((point.x === P0.x && point.y === P0.y) || (point.x === P1.x && point.y === P1.y)) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
const theta = ellipse.computeThetaForPoint(point);
|
|
44
|
-
return +theta >= +minTheta && +theta <= +maxTheta;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
get P0() {
|
|
48
|
-
return this.points[0];
|
|
49
|
-
}
|
|
50
|
-
get P1() {
|
|
51
|
-
if (this.isRelative) {
|
|
52
|
-
return this.P0.clone().translate(this.vectors[0]);
|
|
53
|
-
}
|
|
54
|
-
return this.points[1];
|
|
55
|
-
}
|
|
56
|
-
clone() {
|
|
57
|
-
const values = this.values.map((value) => (typeof value === 'object' && 'clone' in value ? value.clone() : value));
|
|
58
|
-
return new ArcCurve(values);
|
|
59
|
-
}
|
|
60
|
-
reflect(about) {
|
|
61
|
-
super.reflect(about);
|
|
62
|
-
this.sweepFlag.invert();
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
|
-
adjustRadii() {
|
|
66
|
-
const { rx, ry } = this;
|
|
67
|
-
const P0_prime = this.computeP0Prime();
|
|
68
|
-
const { x: x1_prime, y: y1_prime } = P0_prime;
|
|
69
|
-
const rx_sq = Calculator_1.Calculator.pow(+rx, 2);
|
|
70
|
-
const ry_sq = Calculator_1.Calculator.pow(+ry, 2);
|
|
71
|
-
const x1_prime_sq = Calculator_1.Calculator.pow(x1_prime, 2);
|
|
72
|
-
const y1_prime_sq = Calculator_1.Calculator.pow(y1_prime, 2);
|
|
73
|
-
const radii_check = x1_prime_sq.div(rx_sq).add(y1_prime_sq.div(ry_sq));
|
|
74
|
-
if (+radii_check > 1) {
|
|
75
|
-
rx.replace(+Calculator_1.Calculator.mul(+rx, radii_check.sqrt()));
|
|
76
|
-
ry.replace(+Calculator_1.Calculator.mul(+ry, radii_check.sqrt()));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
computeCenter() {
|
|
80
|
-
const { P0, P1, phi } = this;
|
|
81
|
-
const center_prime = this.computeCenterPrime();
|
|
82
|
-
const { x: x1, y: y1 } = P0;
|
|
83
|
-
const { x: x2, y: y2 } = P1;
|
|
84
|
-
const { x: cx_prime, y: cy_prime } = center_prime;
|
|
85
|
-
const dx = Calculator_1.Calculator.add(x1, x2).div(2);
|
|
86
|
-
const dy = Calculator_1.Calculator.add(y1, y2).div(2);
|
|
87
|
-
const cx = Calculator_1.Calculator.mul(phi.cos, cx_prime).sub(Calculator_1.Calculator.mul(phi.sin, cy_prime)).add(dx);
|
|
88
|
-
const cy = Calculator_1.Calculator.mul(phi.sin, cx_prime).add(Calculator_1.Calculator.mul(phi.cos, cy_prime)).add(dy);
|
|
89
|
-
return new Point_1.Point([+cx, +cy]);
|
|
90
|
-
}
|
|
91
|
-
computeCenterPrime() {
|
|
92
|
-
const { largeArcFlag, sweepFlag, rx, ry } = this;
|
|
93
|
-
const P0_prime = this.computeP0Prime();
|
|
94
|
-
const { x: x1_prime, y: y1_prime } = P0_prime;
|
|
95
|
-
const rx_sq = Calculator_1.Calculator.pow(+rx, 2);
|
|
96
|
-
const ry_sq = Calculator_1.Calculator.pow(+ry, 2);
|
|
97
|
-
const x1_prime_sq = Calculator_1.Calculator.pow(x1_prime, 2);
|
|
98
|
-
const y1_prime_sq = Calculator_1.Calculator.pow(y1_prime, 2);
|
|
99
|
-
const sign = new Calculator_1.Calculator(+largeArcFlag === +sweepFlag ? -1 : 1);
|
|
100
|
-
let sq = rx_sq
|
|
101
|
-
.mul(ry_sq)
|
|
102
|
-
.sub(rx_sq.mul(y1_prime_sq))
|
|
103
|
-
.sub(ry_sq.mul(x1_prime_sq))
|
|
104
|
-
.div(rx_sq.mul(y1_prime_sq).add(ry_sq.mul(x1_prime_sq)));
|
|
105
|
-
sq = +sq < 0 ? new Calculator_1.Calculator(0) : sq;
|
|
106
|
-
const coef = sign.mul(sq.sqrt());
|
|
107
|
-
const cx_prime = coef.mul(Calculator_1.Calculator.mul(+rx, y1_prime).div(+ry));
|
|
108
|
-
const cy_prime = coef.mul(Calculator_1.Calculator.mul(+ry, x1_prime).div(+rx).neg());
|
|
109
|
-
return new Point_1.Point([+cx_prime, +cy_prime]);
|
|
110
|
-
}
|
|
111
|
-
computeP0Prime() {
|
|
112
|
-
const { P0, P1, phi } = this;
|
|
113
|
-
const { x: x1, y: y1 } = P0;
|
|
114
|
-
const { x: x2, y: y2 } = P1;
|
|
115
|
-
const mx = Calculator_1.Calculator.sub(x1, x2).div(2);
|
|
116
|
-
const my = Calculator_1.Calculator.sub(y1, y2).div(2);
|
|
117
|
-
const x1_prime = Calculator_1.Calculator.mul(phi.cos, mx).add(Calculator_1.Calculator.mul(phi.sin, my));
|
|
118
|
-
const y1_prime = Calculator_1.Calculator.mul(phi.sin, mx).neg().add(Calculator_1.Calculator.mul(phi.cos, my));
|
|
119
|
-
return new Point_1.Point([+x1_prime, +y1_prime]);
|
|
120
|
-
}
|
|
121
|
-
computeThetaRange() {
|
|
122
|
-
const { P0, P1, ellipse, sweepFlag } = this;
|
|
123
|
-
const theta1 = ellipse.computeThetaForPoint(P0);
|
|
124
|
-
const theta2 = ellipse.computeThetaForPoint(P1);
|
|
125
|
-
if (+theta2 === 0 && !sweepFlag.value) {
|
|
126
|
-
theta2.replace(360, 'degrees');
|
|
127
|
-
}
|
|
128
|
-
const thetaRange = [theta1, theta2].sort((a, b) => +Calculator_1.Calculator.sub(a.radians, b.radians));
|
|
129
|
-
return thetaRange;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
exports.ArcCurve = ArcCurve;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Ellipse = void 0;
|
|
4
|
-
const Calculator_1 = require("../utilities/Calculator");
|
|
5
|
-
const Angle_1 = require("../abstracts/Angle");
|
|
6
|
-
const Point_1 = require("../abstracts/Point");
|
|
7
|
-
const Figure_1 = require("../abstracts/Figure");
|
|
8
|
-
const utilities_1 = require("../utilities");
|
|
9
|
-
class Ellipse extends Figure_1.Figure {
|
|
10
|
-
_center;
|
|
11
|
-
_criticalPoints;
|
|
12
|
-
_phi;
|
|
13
|
-
_rx;
|
|
14
|
-
_ry;
|
|
15
|
-
constructor(values) {
|
|
16
|
-
super(values);
|
|
17
|
-
const [center, rx, ry, phi] = values;
|
|
18
|
-
this._center = center;
|
|
19
|
-
this._rx = rx;
|
|
20
|
-
this._ry = ry;
|
|
21
|
-
this._phi = phi;
|
|
22
|
-
this._criticalPoints = this.computeCriticalPoints({ center, rx, ry, phi });
|
|
23
|
-
}
|
|
24
|
-
get boundingBox() {
|
|
25
|
-
return Figure_1.Figure.computeBoundingBox(this.criticalPoints);
|
|
26
|
-
}
|
|
27
|
-
get center() {
|
|
28
|
-
return this._center;
|
|
29
|
-
}
|
|
30
|
-
get criticalPoints() {
|
|
31
|
-
return this._criticalPoints;
|
|
32
|
-
}
|
|
33
|
-
get isCircle() {
|
|
34
|
-
return +this.rx === +this.ry;
|
|
35
|
-
}
|
|
36
|
-
get phi() {
|
|
37
|
-
return this._phi;
|
|
38
|
-
}
|
|
39
|
-
get rx() {
|
|
40
|
-
return this._rx;
|
|
41
|
-
}
|
|
42
|
-
get ry() {
|
|
43
|
-
return this._ry;
|
|
44
|
-
}
|
|
45
|
-
clone() {
|
|
46
|
-
const values = this.values.map((value) => value.clone());
|
|
47
|
-
return new Ellipse(values);
|
|
48
|
-
}
|
|
49
|
-
computePointForTheta(theta, ellipse = this) {
|
|
50
|
-
const { center, rx, ry, phi } = ellipse;
|
|
51
|
-
const x = +Calculator_1.Calculator.mul(+rx, phi.cos).mul(theta.cos).sub(Calculator_1.Calculator.mul(+ry, phi.sin).mul(theta.sin)).add(center.x);
|
|
52
|
-
const y = +Calculator_1.Calculator.mul(+rx, phi.sin).mul(theta.cos).add(Calculator_1.Calculator.mul(+ry, phi.cos).mul(theta.sin)).add(center.y);
|
|
53
|
-
return new Point_1.Point([x, y]);
|
|
54
|
-
}
|
|
55
|
-
computeThetaForPoint({ x, y }) {
|
|
56
|
-
const { center, phi, rx, ry } = this;
|
|
57
|
-
const { x: cx, y: cy } = center;
|
|
58
|
-
const dy = Calculator_1.Calculator.sub(y, cy);
|
|
59
|
-
const dx = Calculator_1.Calculator.sub(x, cx);
|
|
60
|
-
const sinTheta = dy.mul(phi.cos).sub(dx.mul(phi.sin)).div(+ry);
|
|
61
|
-
const cosTheta = dx.mul(phi.cos).add(dy.mul(phi.sin)).div(+rx);
|
|
62
|
-
const theta = new Angle_1.Angle(+Calculator_1.Calculator.atan2(sinTheta, cosTheta), 'radians').normalize();
|
|
63
|
-
return theta;
|
|
64
|
-
}
|
|
65
|
-
reflect(about) {
|
|
66
|
-
super.reflect(about);
|
|
67
|
-
if (!this.isCircle && 'V' in about) {
|
|
68
|
-
const alpha = about.angleTo(utilities_1.xAxis);
|
|
69
|
-
this._phi.replace(+Calculator_1.Calculator.mul(2, alpha.radians).sub(this.phi.radians), 'radians');
|
|
70
|
-
this._phi.normalize();
|
|
71
|
-
}
|
|
72
|
-
this.recompute();
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
rotate(alpha, about) {
|
|
76
|
-
this._center.rotate(alpha, about);
|
|
77
|
-
if (!this.isCircle) {
|
|
78
|
-
this._phi.replace(+Calculator_1.Calculator.add(this.phi.radians, alpha.radians), 'radians');
|
|
79
|
-
this._phi.normalize();
|
|
80
|
-
}
|
|
81
|
-
this.recompute();
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
scale(factor, about = new Point_1.Point([0, 0])) {
|
|
85
|
-
super.scale(factor, about);
|
|
86
|
-
this.recompute();
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
translate(vector) {
|
|
90
|
-
this._center.translate(vector);
|
|
91
|
-
this.recompute();
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
computeCriticalPoints(ellipse = this) {
|
|
95
|
-
const { rx, ry, phi } = ellipse;
|
|
96
|
-
const { computePointForTheta } = this;
|
|
97
|
-
const xThetaPrincipal = new Angle_1.Angle(+Calculator_1.Calculator.neg(+ry).mul(phi.tan).div(+rx).atan(), 'radians');
|
|
98
|
-
const yThetaPrincipal = new Angle_1.Angle(+Calculator_1.Calculator.mul(+ry, phi.cot).div(+rx).atan(), 'radians');
|
|
99
|
-
const xThetaSecondary = new Angle_1.Angle(+Calculator_1.Calculator.add(+xThetaPrincipal, Math.PI), 'radians');
|
|
100
|
-
const yThetaSecondary = new Angle_1.Angle(+Calculator_1.Calculator.add(+yThetaPrincipal, Math.PI), 'radians');
|
|
101
|
-
const firstPoint = computePointForTheta(xThetaPrincipal, ellipse);
|
|
102
|
-
const secondPoint = computePointForTheta(yThetaPrincipal, ellipse);
|
|
103
|
-
const thirdPoint = computePointForTheta(xThetaSecondary, ellipse);
|
|
104
|
-
const fourthPoint = computePointForTheta(yThetaSecondary, ellipse);
|
|
105
|
-
return [firstPoint, secondPoint, thirdPoint, fourthPoint];
|
|
106
|
-
}
|
|
107
|
-
recompute() {
|
|
108
|
-
this._criticalPoints = this.computeCriticalPoints();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
exports.Ellipse = Ellipse;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Polygon = void 0;
|
|
4
|
-
const Figure_1 = require("../abstracts/Figure");
|
|
5
|
-
class Polygon extends Figure_1.Figure {
|
|
6
|
-
constructor(values) {
|
|
7
|
-
super(values);
|
|
8
|
-
}
|
|
9
|
-
get sides() {
|
|
10
|
-
return this.points.length;
|
|
11
|
-
}
|
|
12
|
-
clone() {
|
|
13
|
-
const values = this.values.map((value) => value.clone());
|
|
14
|
-
return new Polygon(values);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.Polygon = Polygon;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Figure } from '../abstracts/Figure';
|
|
2
|
-
export class Polygon extends Figure {
|
|
3
|
-
constructor(values) {
|
|
4
|
-
super(values);
|
|
5
|
-
}
|
|
6
|
-
get sides() {
|
|
7
|
-
return this.points.length;
|
|
8
|
-
}
|
|
9
|
-
clone() {
|
|
10
|
-
const values = this.values.map((value) => value.clone());
|
|
11
|
-
return new Polygon(values);
|
|
12
|
-
}
|
|
13
|
-
}
|