geometric-library 1.3.0 → 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 +49 -23
- 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} +6 -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} +5 -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} +3 -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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Figure } from '../../abstracts';
|
|
2
|
+
import { Line } from '../line/Line';
|
|
3
|
+
export class Polygon extends Figure {
|
|
4
|
+
_lines;
|
|
5
|
+
constructor(values) {
|
|
6
|
+
super(values);
|
|
7
|
+
this._lines = this.computeLines();
|
|
8
|
+
}
|
|
9
|
+
get lines() {
|
|
10
|
+
return this._lines;
|
|
11
|
+
}
|
|
12
|
+
get sides() {
|
|
13
|
+
return this.points.length;
|
|
14
|
+
}
|
|
15
|
+
clone() {
|
|
16
|
+
const values = this.values.map((value) => value.clone());
|
|
17
|
+
return new Polygon(values);
|
|
18
|
+
}
|
|
19
|
+
reflect(about) {
|
|
20
|
+
super.reflect(about);
|
|
21
|
+
this._lines = this.computeLines();
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
rotate(phi, about) {
|
|
25
|
+
super.rotate(phi, about);
|
|
26
|
+
this._lines = this.computeLines();
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
scale(factor, about) {
|
|
30
|
+
super.scale(factor, about);
|
|
31
|
+
this._lines = this.computeLines();
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
scaleXY(factorX, factorY, about) {
|
|
35
|
+
super.scaleXY(factorX, factorY, about);
|
|
36
|
+
this._lines = this.computeLines();
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
translate(vector) {
|
|
40
|
+
super.translate(vector);
|
|
41
|
+
this._lines = this.computeLines();
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
computeLines() {
|
|
45
|
+
return this.points.map((point, i) => new Line([point, this.points[(i + 1) % this.points.length]]));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/figures/{QuadraticBezierCurve.js → quadratic-bezier-curve/QuadraticBezierCurve.js}
RENAMED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Figure } from '../abstracts/Figure';
|
|
1
|
+
import { Figure, Point } from '../../abstracts';
|
|
2
|
+
import { Calculator } from '../../utilities/calculator';
|
|
4
3
|
export class QuadraticBezierCurve extends Figure {
|
|
5
4
|
_criticalPoints;
|
|
6
5
|
constructor(values) {
|
|
@@ -52,6 +51,11 @@ export class QuadraticBezierCurve extends Figure {
|
|
|
52
51
|
this.recompute();
|
|
53
52
|
return this;
|
|
54
53
|
}
|
|
54
|
+
scaleXY(factorX, factorY, about) {
|
|
55
|
+
super.scaleXY(factorX, factorY, about);
|
|
56
|
+
this.recompute();
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
55
59
|
translate(vector) {
|
|
56
60
|
super.translate(vector);
|
|
57
61
|
this.recompute();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
/* v8 ignore */
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export { Flag } from './abstracts/Flag';
|
|
5
|
-
export { Magnitude } from './abstracts/Magnitude';
|
|
6
|
-
export { Point } from './abstracts/Point';
|
|
7
|
-
export { Vector } from './abstracts/Vector.js';
|
|
8
|
-
export { ArcCurve } from './figures/ArcCurve';
|
|
9
|
-
export { Circle } from './figures/Circle';
|
|
10
|
-
export { CubicBezierCurve } from './figures/CubicBezierCurve';
|
|
11
|
-
export { Ellipse } from './figures/Ellipse';
|
|
12
|
-
export { Line } from './figures/Line';
|
|
13
|
-
export { Polygon } from './figures/Polygon';
|
|
14
|
-
export { QuadraticBezierCurve } from './figures/QuadraticBezierCurve';
|
|
15
|
-
export { Calculator } from './utilities/Calculator';
|
|
2
|
+
export * from './abstracts';
|
|
3
|
+
export * from './figures';
|
|
16
4
|
export * from './utilities';
|
|
17
5
|
export * from './types';
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Decimal } from 'decimal.js';
|
|
2
2
|
export class Calculator {
|
|
3
|
+
static EPSILON = 1e-8;
|
|
4
|
+
static PI2 = +Calculator.mul(Math.PI, 2);
|
|
3
5
|
_instance;
|
|
4
6
|
constructor(arg) {
|
|
5
7
|
this._instance = new Decimal(arg);
|
|
@@ -26,6 +28,12 @@ export class Calculator {
|
|
|
26
28
|
static div(first, second) {
|
|
27
29
|
return Calculator.computeBinaryOperation('div', [first, second]);
|
|
28
30
|
}
|
|
31
|
+
static isEqual(a, b) {
|
|
32
|
+
return Math.abs(a - b) <= Calculator.EPSILON;
|
|
33
|
+
}
|
|
34
|
+
static isNearZero(a) {
|
|
35
|
+
return Math.abs(a) <= Calculator.EPSILON;
|
|
36
|
+
}
|
|
29
37
|
static max(args) {
|
|
30
38
|
return Calculator.computeIndefiniteOperation('max', args);
|
|
31
39
|
}
|
|
@@ -80,7 +88,7 @@ export class Calculator {
|
|
|
80
88
|
* than epsilon, and then to round up to that point instead of choosing an arbitrary precision.
|
|
81
89
|
*/
|
|
82
90
|
static roundDecimalWithPrecision(value) {
|
|
83
|
-
const epsilon = new Decimal(
|
|
91
|
+
const epsilon = new Decimal(Calculator.EPSILON);
|
|
84
92
|
const distanceToLowerInt = value.sub(value.floor());
|
|
85
93
|
const distanceToUpperInt = value.ceil().sub(value);
|
|
86
94
|
if (distanceToLowerInt.lte(epsilon)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Calculator';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Calculator } from './
|
|
2
|
-
import { Point } from '../abstracts
|
|
3
|
-
|
|
1
|
+
import { Calculator } from './calculator';
|
|
2
|
+
import { Point } from '../abstracts';
|
|
3
|
+
export * from './calculator';
|
|
4
4
|
export const coordinateOrigin = new Point([0, 0]);
|
|
5
|
-
export const
|
|
6
|
-
export const yAxis = new Line([coordinateOrigin, new Point([0, 1])]);
|
|
7
|
-
export const PI2 = +Calculator.mul(Math.PI, 2); // 360 degrees
|
|
5
|
+
export const PI2 = Calculator.PI2;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IClonable } from '../../types';
|
|
2
|
+
export type TAngleUnit = 'radians' | 'degrees';
|
|
3
|
+
export interface IAngle extends IClonable<IAngle> {
|
|
4
|
+
readonly cos: number;
|
|
5
|
+
readonly cot: number;
|
|
6
|
+
readonly degrees: number;
|
|
7
|
+
readonly kind: 'angle';
|
|
8
|
+
readonly radians: number;
|
|
9
|
+
readonly sin: number;
|
|
10
|
+
readonly tan: number;
|
|
11
|
+
normalize(): this;
|
|
12
|
+
replace(value: number, unit: TAngleUnit): this;
|
|
13
|
+
scale(factor: number): this;
|
|
14
|
+
valueOf(): number;
|
|
15
|
+
}
|
|
16
|
+
export type TAngleRange = [IAngle, IAngle];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { IAngle,
|
|
1
|
+
import { IAngle, IFigure, IMagnitude, IPoint, IVector, TFigureValues } from '..';
|
|
2
|
+
import type { ILine } from '../../figures';
|
|
3
|
+
import { IBoundingBox } from '../../types';
|
|
2
4
|
export declare abstract class Figure implements IFigure {
|
|
3
5
|
protected angles: IAngle[];
|
|
4
6
|
protected isRelative: boolean;
|
|
@@ -9,14 +11,12 @@ export declare abstract class Figure implements IFigure {
|
|
|
9
11
|
constructor(values: TFigureValues);
|
|
10
12
|
get boundingBox(): IBoundingBox;
|
|
11
13
|
get values(): TFigureValues;
|
|
12
|
-
/**
|
|
13
|
-
* @todo Figure out a better way to type narrow than iterating again.
|
|
14
|
-
*/
|
|
15
14
|
protected set values(values: TFigureValues);
|
|
16
15
|
protected static computeBoundingBox(points: IPoint[]): IBoundingBox;
|
|
17
16
|
private static getNoPointsErrorMessage;
|
|
18
17
|
reflect(about: IPoint | ILine): this;
|
|
19
18
|
rotate(phi: IAngle, about?: IPoint): this;
|
|
20
19
|
scale(factor: number, about?: IPoint): this;
|
|
20
|
+
scaleXY(factorX: number, factorY: number, about?: IPoint): this;
|
|
21
21
|
translate(vector: IVector): this;
|
|
22
22
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IAngle, IFlag, IMagnitude, IPoint, IVector } from '..';
|
|
2
|
+
import { ILine } from '../../figures';
|
|
3
|
+
import { IBoundingBox } from '../../types';
|
|
4
|
+
export type TFigureValue = IFlag | IMagnitude | IAngle | IPoint | IVector;
|
|
5
|
+
export type TFigureValues = [IPoint, ...TFigureValue[]];
|
|
6
|
+
export interface IFigure {
|
|
7
|
+
readonly boundingBox: IBoundingBox;
|
|
8
|
+
readonly values: TFigureValues;
|
|
9
|
+
reflect(about: IPoint | ILine): this;
|
|
10
|
+
rotate(phi: IAngle, about?: IPoint): this;
|
|
11
|
+
scale(factor: number, about?: IPoint): this;
|
|
12
|
+
scaleXY(factorX: number, factorY: number, about?: IPoint): this;
|
|
13
|
+
translate(vector: IVector): this;
|
|
14
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { IMagnitude } from '
|
|
1
|
+
import { IMagnitude } from './Magnitude.types';
|
|
2
2
|
export declare class Magnitude implements IMagnitude {
|
|
3
|
+
readonly kind: "magnitude";
|
|
3
4
|
private _value;
|
|
4
5
|
constructor(value: number);
|
|
6
|
+
get value(): number;
|
|
5
7
|
clone(): IMagnitude;
|
|
6
8
|
replace(value: number): this;
|
|
7
9
|
scale(factor: number): this;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IAngle, IVector } from '..';
|
|
2
|
+
import { IClonable } from '../../types';
|
|
3
|
+
export type TPointValues = [number, number];
|
|
4
|
+
export interface IPoint extends IClonable<IPoint> {
|
|
5
|
+
readonly kind: 'point';
|
|
6
|
+
readonly values: TPointValues;
|
|
7
|
+
readonly x: number;
|
|
8
|
+
readonly y: number;
|
|
9
|
+
reflect(about: IPoint): this;
|
|
10
|
+
replace(point: IPoint): this;
|
|
11
|
+
rotate(phi: IAngle, about?: IPoint): this;
|
|
12
|
+
translate(vector: IVector): this;
|
|
13
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { IVector, TVectorValues,
|
|
1
|
+
import { IVector, TVectorValues, IAngle } from '..';
|
|
2
|
+
import type { TSegment } from '../../figures';
|
|
2
3
|
export declare class Vector implements IVector {
|
|
4
|
+
readonly kind: "vector";
|
|
3
5
|
private _dx;
|
|
4
6
|
private _dy;
|
|
5
7
|
constructor(values: TVectorValues | TSegment);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IAngle } from '..';
|
|
2
|
+
import { IClonable } from '../../types';
|
|
3
|
+
export type TVectorValues = [number, number];
|
|
4
|
+
export interface IVector extends IClonable<IVector> {
|
|
5
|
+
readonly dx: number;
|
|
6
|
+
readonly dy: number;
|
|
7
|
+
readonly kind: 'vector';
|
|
8
|
+
readonly magnitude: number;
|
|
9
|
+
readonly values: TVectorValues;
|
|
10
|
+
angleTo(vector: IVector): IAngle;
|
|
11
|
+
dotProduct(vector: IVector): number;
|
|
12
|
+
reflect(about: {
|
|
13
|
+
x: boolean;
|
|
14
|
+
y: boolean;
|
|
15
|
+
}): this;
|
|
16
|
+
replace(vector: IVector): this;
|
|
17
|
+
rotate(phi: IAngle): this;
|
|
18
|
+
scale(factor: number): this;
|
|
19
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Figure, IPoint } from '../../abstracts';
|
|
2
|
+
import { CubicBezierCurve } from '../cubic-bezier-curve/CubicBezierCurve';
|
|
3
|
+
import type { IArcCurve, ILine, TArcValues } from '..';
|
|
4
|
+
import { IBoundingBox } from '../../types';
|
|
3
5
|
export declare class ArcCurve extends Figure implements IArcCurve {
|
|
4
6
|
private ellipse;
|
|
5
7
|
private largeArcFlag;
|
|
@@ -15,9 +17,12 @@ export declare class ArcCurve extends Figure implements IArcCurve {
|
|
|
15
17
|
private get P1();
|
|
16
18
|
clone(): ArcCurve;
|
|
17
19
|
reflect(about: IPoint | ILine): this;
|
|
20
|
+
toCubicBezierCurves(): CubicBezierCurve[];
|
|
18
21
|
private adjustRadii;
|
|
22
|
+
private computeBezierSegment;
|
|
19
23
|
private computeCenter;
|
|
20
24
|
private computeCenterPrime;
|
|
21
25
|
private computeP0Prime;
|
|
26
|
+
private computeTangentForTheta;
|
|
22
27
|
private computeThetaRange;
|
|
23
28
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IAngle, IFigure, IFlag, IMagnitude, IPoint, IVector } from '../../abstracts';
|
|
2
|
+
import type { CubicBezierCurve } from '../cubic-bezier-curve/CubicBezierCurve';
|
|
3
|
+
import { IClonable } from '../../types';
|
|
4
|
+
export type TArcAbsoluteValues = [IPoint, IMagnitude, IMagnitude, IAngle, IFlag, IFlag, IPoint];
|
|
5
|
+
export type TArcRelativeValues = [IPoint, IMagnitude, IMagnitude, IAngle, IFlag, IFlag, IVector];
|
|
6
|
+
export type TArcValues = TArcAbsoluteValues | TArcRelativeValues;
|
|
7
|
+
export interface IArcCurve extends IFigure, IClonable<IArcCurve> {
|
|
8
|
+
readonly center: IPoint;
|
|
9
|
+
readonly criticalPoints: IPoint[];
|
|
10
|
+
toCubicBezierCurves(): CubicBezierCurve[];
|
|
11
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Ellipse } from '
|
|
1
|
+
import { IMagnitude, TFigureValues } from '../../abstracts';
|
|
2
|
+
import { Ellipse } from '../ellipse/Ellipse';
|
|
3
|
+
import type { ICircle, IEllipse, TCircleValues, TEllipseCriticalPoints } from '..';
|
|
3
4
|
export declare class Circle extends Ellipse implements ICircle {
|
|
4
5
|
private _radius;
|
|
5
6
|
constructor(values: TCircleValues);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IFigure, IMagnitude, IPoint } from '../../abstracts';
|
|
2
|
+
import { TEllipseCriticalPoints } from '..';
|
|
3
|
+
import { IClonable } from '../../types';
|
|
4
|
+
export type TCircleValues = [IPoint, IMagnitude];
|
|
5
|
+
export interface ICircle extends IFigure, IClonable<ICircle> {
|
|
6
|
+
readonly center: IPoint;
|
|
7
|
+
readonly criticalPoints: TEllipseCriticalPoints;
|
|
8
|
+
readonly radius: IMagnitude;
|
|
9
|
+
}
|
package/dist/types/figures/{CubicBezierCurve.d.ts → cubic-bezier-curve/CubicBezierCurve.d.ts}
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Figure, IAngle, IPoint, IVector } from '../../abstracts';
|
|
2
|
+
import type { ICubicBezierCurve, ILine, TCubicBezierValues } from '..';
|
|
3
|
+
import { IBoundingBox } from '../../types';
|
|
3
4
|
export declare class CubicBezierCurve extends Figure implements ICubicBezierCurve {
|
|
4
5
|
private _criticalPoints;
|
|
5
6
|
constructor(values: TCubicBezierValues);
|
|
@@ -14,6 +15,7 @@ export declare class CubicBezierCurve extends Figure implements ICubicBezierCurv
|
|
|
14
15
|
reflect(about: IPoint | ILine): this;
|
|
15
16
|
rotate(phi: IAngle, about?: IPoint | undefined): this;
|
|
16
17
|
scale(factor: number, about?: IPoint): this;
|
|
18
|
+
scaleXY(factorX: number, factorY: number, about?: IPoint): this;
|
|
17
19
|
translate(vector: IVector): this;
|
|
18
20
|
private computeCriticalPoints;
|
|
19
21
|
private computeCriticalPointsTValues;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IFigure, IPoint, IVector } from '../../abstracts';
|
|
2
|
+
import { IClonable } from '../../types';
|
|
3
|
+
export type TCubicBezierAbsoluteValues = [IPoint, IPoint, IPoint, IPoint];
|
|
4
|
+
export type TCubicBezierRelativeValues = [IPoint, IVector, IVector, IVector];
|
|
5
|
+
export type TCubicBezierValues = TCubicBezierAbsoluteValues | TCubicBezierRelativeValues;
|
|
6
|
+
export interface ICubicBezierCurve extends IFigure, IClonable<ICubicBezierCurve> {
|
|
7
|
+
readonly criticalPoints: IPoint[];
|
|
8
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Figure, IAngle, IMagnitude, IPoint, IVector } from '../../abstracts';
|
|
2
|
+
import type { IEllipse, ILine, TEllipseCriticalPoints, TEllipseValues } from '..';
|
|
3
|
+
import type { TEllipseCubicBezierCurves } from './Ellipse.types';
|
|
4
|
+
import { IBoundingBox } from '../../types';
|
|
3
5
|
export declare class Ellipse extends Figure implements IEllipse {
|
|
4
6
|
private _center;
|
|
5
7
|
private _criticalPoints;
|
|
@@ -20,6 +22,7 @@ export declare class Ellipse extends Figure implements IEllipse {
|
|
|
20
22
|
reflect(about: IPoint | ILine): this;
|
|
21
23
|
rotate(alpha: IAngle, about?: IPoint | undefined): this;
|
|
22
24
|
scale(factor: number, about?: IPoint): this;
|
|
25
|
+
toCubicBezierCurves(): TEllipseCubicBezierCurves;
|
|
23
26
|
translate(vector: IVector): this;
|
|
24
27
|
protected computeCriticalPoints(ellipse?: IEllipse): TEllipseCriticalPoints;
|
|
25
28
|
private recompute;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IAngle, IFigure, IMagnitude, IPoint } from '../../abstracts';
|
|
2
|
+
import { CubicBezierCurve } from '../cubic-bezier-curve';
|
|
3
|
+
import { IClonable } from '../../types';
|
|
4
|
+
export type TEllipseValues = [IPoint, IMagnitude, IMagnitude, IAngle];
|
|
5
|
+
export type TEllipseCriticalPoints = [IPoint, IPoint, IPoint, IPoint];
|
|
6
|
+
export type TEllipseCubicBezierCurves = [CubicBezierCurve, CubicBezierCurve, CubicBezierCurve, CubicBezierCurve];
|
|
7
|
+
export interface IEllipse extends IFigure, IClonable<IEllipse> {
|
|
8
|
+
readonly center: IPoint;
|
|
9
|
+
readonly criticalPoints: TEllipseCriticalPoints;
|
|
10
|
+
readonly phi: IAngle;
|
|
11
|
+
readonly rx: IMagnitude;
|
|
12
|
+
readonly ry: IMagnitude;
|
|
13
|
+
computePointForTheta(theta: IAngle): IPoint;
|
|
14
|
+
computeThetaForPoint(point: IPoint): IAngle;
|
|
15
|
+
toCubicBezierCurves(): TEllipseCubicBezierCurves;
|
|
16
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Figure, IAngle, IPoint, IVector } from '../../abstracts';
|
|
2
|
+
import type { ILine, TLineValues } from '..';
|
|
3
3
|
export declare class Line extends Figure implements ILine {
|
|
4
4
|
private _P0;
|
|
5
5
|
private _P1;
|
|
6
6
|
private _V;
|
|
7
|
+
private _dirty;
|
|
7
8
|
private _reciprocal;
|
|
8
9
|
private _slope;
|
|
9
10
|
private _xIntercept;
|
|
@@ -21,7 +22,7 @@ export declare class Line extends Figure implements ILine {
|
|
|
21
22
|
get slope(): number | undefined;
|
|
22
23
|
get xIntercept(): number | undefined;
|
|
23
24
|
get yIntercept(): number | undefined;
|
|
24
|
-
angleTo(
|
|
25
|
+
angleTo(reference: ILine | IVector): IAngle;
|
|
25
26
|
clone(): Line;
|
|
26
27
|
getIntersectionPoint(line: ILine): IPoint | undefined;
|
|
27
28
|
getPerpendicularProjection(point: IPoint): IPoint;
|
|
@@ -35,10 +36,11 @@ export declare class Line extends Figure implements ILine {
|
|
|
35
36
|
reflect(about: ILine | IPoint): this;
|
|
36
37
|
rotate(phi: IAngle, about?: IPoint | undefined): this;
|
|
37
38
|
scale(factor: number, about?: IPoint): this;
|
|
39
|
+
scaleXY(factorX: number, factorY: number, about?: IPoint): this;
|
|
38
40
|
translate(vector: IVector): this;
|
|
39
41
|
private computeReciprocal;
|
|
40
42
|
private computeSlope;
|
|
41
43
|
private computeXIntercept;
|
|
42
44
|
private computeYIntercept;
|
|
43
|
-
private
|
|
45
|
+
private ensureComputed;
|
|
44
46
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IAngle, IFigure, IPoint, IVector } from '../../abstracts';
|
|
2
|
+
import { IClonable } from '../../types';
|
|
3
|
+
export type TSegment = [IPoint, IPoint];
|
|
4
|
+
export type TLineRelativeValues = [IPoint, IVector];
|
|
5
|
+
export type TLineAbsoluteValues = [IPoint, IPoint];
|
|
6
|
+
export type TLineValues = TLineAbsoluteValues | TLineRelativeValues;
|
|
7
|
+
export interface ILine extends IFigure, IClonable<ILine> {
|
|
8
|
+
readonly P0: IPoint;
|
|
9
|
+
readonly P1: IPoint;
|
|
10
|
+
readonly V: IVector;
|
|
11
|
+
readonly a: number;
|
|
12
|
+
readonly b: number;
|
|
13
|
+
readonly c: number;
|
|
14
|
+
readonly isHorizontal: boolean;
|
|
15
|
+
readonly isVertical: boolean;
|
|
16
|
+
readonly reciprocal: number | undefined;
|
|
17
|
+
readonly slope: number | undefined;
|
|
18
|
+
readonly xIntercept: number | undefined;
|
|
19
|
+
readonly yIntercept: number | undefined;
|
|
20
|
+
angleTo(reference: ILine | IVector): IAngle;
|
|
21
|
+
getIntersectionPoint(line: ILine): IPoint | undefined;
|
|
22
|
+
getPerpendicularProjection(point: IPoint): IPoint;
|
|
23
|
+
getPerpendicularThrough(point: IPoint): ILine;
|
|
24
|
+
getPointAtParameter(t: number): IPoint;
|
|
25
|
+
getXValueAtY(y: number): number | undefined;
|
|
26
|
+
getYValueAtX(x: number): number | undefined;
|
|
27
|
+
hasPoint(point: IPoint): boolean;
|
|
28
|
+
isParallelTo(line: ILine): boolean;
|
|
29
|
+
isPerpendicularTo(line: ILine): boolean;
|
|
30
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IPolygon, TPolygonValues } from '..';
|
|
2
|
+
import { Figure, IAngle, IPoint, IVector } from '../../abstracts';
|
|
3
|
+
import type { ILine } from '../line/Line.types';
|
|
4
|
+
import { Line } from '../line/Line';
|
|
5
|
+
export declare class Polygon extends Figure implements IPolygon {
|
|
6
|
+
private _lines;
|
|
7
|
+
constructor(values: TPolygonValues);
|
|
8
|
+
get lines(): Line[];
|
|
9
|
+
get sides(): number;
|
|
10
|
+
clone(): Polygon;
|
|
11
|
+
reflect(about: IPoint | ILine): this;
|
|
12
|
+
rotate(phi: IAngle, about?: IPoint): this;
|
|
13
|
+
scale(factor: number, about?: IPoint): this;
|
|
14
|
+
scaleXY(factorX: number, factorY: number, about?: IPoint): this;
|
|
15
|
+
translate(vector: IVector): this;
|
|
16
|
+
private computeLines;
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IFigure, IPoint } from '../../abstracts';
|
|
2
|
+
import type { ILine } from '../line/Line.types';
|
|
3
|
+
import { IClonable } from '../../types';
|
|
4
|
+
export type TPolygonValues = [IPoint, IPoint, IPoint, ...IPoint[]];
|
|
5
|
+
export interface IPolygon extends IFigure, IClonable<IPolygon> {
|
|
6
|
+
readonly lines: ILine[];
|
|
7
|
+
readonly sides: number;
|
|
8
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Figure, IAngle, IPoint, IVector } from '../../abstracts';
|
|
2
|
+
import type { ILine, IQuadraticBezierCurve, TQuadraticBezierValues } from '..';
|
|
3
|
+
import { IBoundingBox } from '../../types';
|
|
3
4
|
export declare class QuadraticBezierCurve extends Figure implements IQuadraticBezierCurve {
|
|
4
5
|
private _criticalPoints;
|
|
5
6
|
constructor(values: TQuadraticBezierValues);
|
|
@@ -13,6 +14,7 @@ export declare class QuadraticBezierCurve extends Figure implements IQuadraticBe
|
|
|
13
14
|
reflect(about: IPoint | ILine): this;
|
|
14
15
|
rotate(phi: IAngle, about?: IPoint | undefined): this;
|
|
15
16
|
scale(factor: number, about?: IPoint): this;
|
|
17
|
+
scaleXY(factorX: number, factorY: number, about?: IPoint): this;
|
|
16
18
|
translate(vector: IVector): this;
|
|
17
19
|
private computeCriticalPoints;
|
|
18
20
|
private getCoordinateAtParameter;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IFigure, IPoint, IVector } from '../../abstracts';
|
|
2
|
+
import { IClonable } from '../../types';
|
|
3
|
+
export type TQuadraticBezierAbsoluteValues = [IPoint, IPoint, IPoint];
|
|
4
|
+
export type TQuadraticBezierRelativeValues = [IPoint, IVector, IVector];
|
|
5
|
+
export type TQuadraticBezierValues = TQuadraticBezierAbsoluteValues | TQuadraticBezierRelativeValues;
|
|
6
|
+
export interface IQuadraticBezierCurve extends IFigure, IClonable<IQuadraticBezierCurve> {
|
|
7
|
+
readonly criticalPoints: IPoint[];
|
|
8
|
+
}
|