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,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
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export { Flag } from './abstracts/Flag';
|
|
4
|
-
export { Magnitude } from './abstracts/Magnitude';
|
|
5
|
-
export { Point } from './abstracts/Point';
|
|
6
|
-
export { Vector } from './abstracts/Vector.js';
|
|
7
|
-
export { ArcCurve } from './figures/ArcCurve';
|
|
8
|
-
export { Circle } from './figures/Circle';
|
|
9
|
-
export { CubicBezierCurve } from './figures/CubicBezierCurve';
|
|
10
|
-
export { Ellipse } from './figures/Ellipse';
|
|
11
|
-
export { Line } from './figures/Line';
|
|
12
|
-
export { Polygon } from './figures/Polygon';
|
|
13
|
-
export { QuadraticBezierCurve } from './figures/QuadraticBezierCurve';
|
|
14
|
-
export { Calculator } from './utilities/Calculator';
|
|
1
|
+
export * from './abstracts';
|
|
2
|
+
export * from './figures';
|
|
15
3
|
export * from './utilities';
|
|
16
4
|
export * from './types';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export type TSegment = [IPoint, IPoint];
|
|
2
1
|
export type TAxis = 'x' | 'y';
|
|
3
2
|
export type TAxii = ['x', 'y'];
|
|
4
3
|
export interface IBoundingBox {
|
|
@@ -14,131 +13,3 @@ export interface ISize {
|
|
|
14
13
|
export interface IClonable<T> {
|
|
15
14
|
clone(): T;
|
|
16
15
|
}
|
|
17
|
-
export interface IFlag extends IClonable<IFlag> {
|
|
18
|
-
readonly value: boolean;
|
|
19
|
-
invert(): this;
|
|
20
|
-
replace(value: boolean): this;
|
|
21
|
-
valueOf(): number;
|
|
22
|
-
}
|
|
23
|
-
export type TAngleUnit = 'radians' | 'degrees';
|
|
24
|
-
export interface IAngle extends IClonable<IAngle> {
|
|
25
|
-
readonly cos: number;
|
|
26
|
-
readonly cot: number;
|
|
27
|
-
readonly degrees: number;
|
|
28
|
-
readonly radians: number;
|
|
29
|
-
readonly sin: number;
|
|
30
|
-
readonly tan: number;
|
|
31
|
-
normalize(): this;
|
|
32
|
-
replace(value: number, unit: TAngleUnit): this;
|
|
33
|
-
scale(factor: number): this;
|
|
34
|
-
valueOf(): number;
|
|
35
|
-
}
|
|
36
|
-
export type TAngleRange = [IAngle, IAngle];
|
|
37
|
-
export interface IMagnitude extends IClonable<IMagnitude> {
|
|
38
|
-
readonly value: number;
|
|
39
|
-
replace(value: number): this;
|
|
40
|
-
scale(factor: number): this;
|
|
41
|
-
valueOf(): number;
|
|
42
|
-
}
|
|
43
|
-
export type TPointValues = [number, number];
|
|
44
|
-
export interface IPoint extends IClonable<IPoint> {
|
|
45
|
-
readonly values: TPointValues;
|
|
46
|
-
readonly x: number;
|
|
47
|
-
readonly y: number;
|
|
48
|
-
reflect(about: IPoint): this;
|
|
49
|
-
replace(point: IPoint): this;
|
|
50
|
-
rotate(phi: IAngle, about?: IPoint): this;
|
|
51
|
-
translate(vector: IVector): this;
|
|
52
|
-
}
|
|
53
|
-
export type TVectorValues = [number, number];
|
|
54
|
-
export interface IVector extends IClonable<IVector> {
|
|
55
|
-
readonly dx: number;
|
|
56
|
-
readonly dy: number;
|
|
57
|
-
readonly values: TVectorValues;
|
|
58
|
-
angleTo(vector: IVector): IAngle;
|
|
59
|
-
dotProduct(vector: IVector): number;
|
|
60
|
-
reflect(about: {
|
|
61
|
-
x: boolean;
|
|
62
|
-
y: boolean;
|
|
63
|
-
}): this;
|
|
64
|
-
replace(vector: IVector): this;
|
|
65
|
-
rotate(phi: IAngle): this;
|
|
66
|
-
scale(factor: number): this;
|
|
67
|
-
}
|
|
68
|
-
export type TFigureValue = IFlag | IMagnitude | IAngle | IPoint | IVector;
|
|
69
|
-
export type TFigureValues = [IPoint, ...TFigureValue[]];
|
|
70
|
-
export interface IFigure {
|
|
71
|
-
readonly boundingBox: IBoundingBox;
|
|
72
|
-
readonly values: TFigureValues;
|
|
73
|
-
reflect(about: IPoint | ILine): this;
|
|
74
|
-
rotate(phi: IAngle, about?: IPoint): this;
|
|
75
|
-
scale(factor: number, about?: IPoint): this;
|
|
76
|
-
translate(vector: IVector): this;
|
|
77
|
-
}
|
|
78
|
-
export type TLineRelativeValues = [IPoint, IVector];
|
|
79
|
-
export type TLineAbsoluteValues = [IPoint, IPoint];
|
|
80
|
-
export type TLineValues = TLineAbsoluteValues | TLineRelativeValues;
|
|
81
|
-
export interface ILine extends IFigure, IClonable<ILine> {
|
|
82
|
-
readonly P0: IPoint;
|
|
83
|
-
readonly P1: IPoint;
|
|
84
|
-
readonly V: IVector;
|
|
85
|
-
readonly a: number;
|
|
86
|
-
readonly b: number;
|
|
87
|
-
readonly c: number;
|
|
88
|
-
readonly isHorizontal: boolean;
|
|
89
|
-
readonly isVertical: boolean;
|
|
90
|
-
readonly reciprocal: number | undefined;
|
|
91
|
-
readonly slope: number | undefined;
|
|
92
|
-
readonly xIntercept: number | undefined;
|
|
93
|
-
readonly yIntercept: number | undefined;
|
|
94
|
-
angleTo(reference: ILine | IVector): IAngle;
|
|
95
|
-
getIntersectionPoint(line: ILine): IPoint | undefined;
|
|
96
|
-
getPerpendicularProjection(point: IPoint): IPoint;
|
|
97
|
-
getPerpendicularThrough(point: IPoint): ILine;
|
|
98
|
-
getPointAtParameter(t: number): IPoint | undefined;
|
|
99
|
-
getXValueAtY(y: number): number | undefined;
|
|
100
|
-
getYValueAtX(x: number): number | undefined;
|
|
101
|
-
hasPoint(point: IPoint): boolean;
|
|
102
|
-
isParallelTo(line: ILine): boolean;
|
|
103
|
-
isPerpendicularTo(line: ILine): boolean;
|
|
104
|
-
}
|
|
105
|
-
export type TEllipseValues = [IPoint, IMagnitude, IMagnitude, IAngle];
|
|
106
|
-
export type TEllipseCriticalPoints = [IPoint, IPoint, IPoint, IPoint];
|
|
107
|
-
export interface IEllipse extends IFigure, IClonable<IEllipse> {
|
|
108
|
-
readonly center: IPoint;
|
|
109
|
-
readonly criticalPoints: TEllipseCriticalPoints;
|
|
110
|
-
readonly phi: IAngle;
|
|
111
|
-
readonly rx: IMagnitude;
|
|
112
|
-
readonly ry: IMagnitude;
|
|
113
|
-
computePointForTheta(theta: IAngle): IPoint;
|
|
114
|
-
computeThetaForPoint(point: IPoint): IAngle;
|
|
115
|
-
}
|
|
116
|
-
export type TCircleValues = [IPoint, IMagnitude];
|
|
117
|
-
export interface ICircle extends IFigure, IClonable<ICircle> {
|
|
118
|
-
readonly center: IPoint;
|
|
119
|
-
readonly criticalPoints: TEllipseCriticalPoints;
|
|
120
|
-
readonly radius: IMagnitude;
|
|
121
|
-
}
|
|
122
|
-
export type TArcAbsoluteValues = [IPoint, IMagnitude, IMagnitude, IAngle, IFlag, IFlag, IPoint];
|
|
123
|
-
export type TArcRelativeValues = [IPoint, IMagnitude, IMagnitude, IAngle, IFlag, IFlag, IVector];
|
|
124
|
-
export type TArcValues = TArcAbsoluteValues | TArcRelativeValues;
|
|
125
|
-
export interface IArcCurve extends IFigure, IClonable<IArcCurve> {
|
|
126
|
-
readonly center: IPoint;
|
|
127
|
-
readonly criticalPoints: IPoint[];
|
|
128
|
-
}
|
|
129
|
-
export type TCubicBezierAbsoluteValues = [IPoint, IPoint, IPoint, IPoint];
|
|
130
|
-
export type TCubicBezierRelativeValues = [IPoint, IVector, IVector, IVector];
|
|
131
|
-
export type TCubicBezierValues = TCubicBezierAbsoluteValues | TCubicBezierRelativeValues;
|
|
132
|
-
export interface ICubicBezierCurve extends IFigure, IClonable<ICubicBezierCurve> {
|
|
133
|
-
readonly criticalPoints: IPoint[];
|
|
134
|
-
}
|
|
135
|
-
export type TQuadraticBezierAbsoluteValues = [IPoint, IPoint, IPoint];
|
|
136
|
-
export type TQuadraticBezierRelativeValues = [IPoint, IVector, IVector];
|
|
137
|
-
export type TQuadraticBezierValues = TQuadraticBezierAbsoluteValues | TQuadraticBezierRelativeValues;
|
|
138
|
-
export interface IQuadraticBezierCurve extends IFigure, IClonable<IQuadraticBezierCurve> {
|
|
139
|
-
readonly criticalPoints: IPoint[];
|
|
140
|
-
}
|
|
141
|
-
export type TPolygonValues = [IPoint, IPoint, IPoint, ...IPoint[]];
|
|
142
|
-
export interface IPolygon extends IFigure, IClonable<IPolygon> {
|
|
143
|
-
readonly sides: number;
|
|
144
|
-
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
type TInput = Calculator | number;
|
|
2
2
|
export declare class Calculator {
|
|
3
|
+
static readonly EPSILON: number;
|
|
4
|
+
static readonly PI2: number;
|
|
3
5
|
private _instance;
|
|
4
6
|
constructor(arg: number);
|
|
5
7
|
static abs(arg: TInput): Calculator;
|
|
@@ -9,6 +11,8 @@ export declare class Calculator {
|
|
|
9
11
|
static atan2(first: TInput, second: TInput): Calculator;
|
|
10
12
|
static cos(arg: TInput): Calculator;
|
|
11
13
|
static div(first: TInput, second: TInput): Calculator;
|
|
14
|
+
static isEqual(a: number, b: number): boolean;
|
|
15
|
+
static isNearZero(a: number): boolean;
|
|
12
16
|
static max(args: TInput[]): Calculator;
|
|
13
17
|
static min(args: TInput[]): Calculator;
|
|
14
18
|
static mod(first: TInput, second: TInput): Calculator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Calculator';
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Point } from '../abstracts
|
|
2
|
-
|
|
1
|
+
import { Point } from '../abstracts';
|
|
2
|
+
export * from './calculator';
|
|
3
3
|
export declare const coordinateOrigin: Point;
|
|
4
|
-
export declare const xAxis: Line;
|
|
5
|
-
export declare const yAxis: Line;
|
|
6
4
|
export declare const PI2: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "geometric-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "A Node based, visually agnostic implementation of geometric functions, both abstract and finite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"geometry",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"types": "dist/types/index.d.ts",
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:types",
|
|
27
|
-
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
28
|
-
"build:esm": "tsc --project tsconfig.esm.json",
|
|
29
|
-
"build:types": "tsc --project tsconfig.types.json",
|
|
27
|
+
"build:cjs": "tsc --project tsconfig.cjs.json && tsc-alias -p tsconfig.cjs.json",
|
|
28
|
+
"build:esm": "tsc --project tsconfig.esm.json && tsc-alias -p tsconfig.esm.json",
|
|
29
|
+
"build:types": "tsc --project tsconfig.types.json && tsc-alias -p tsconfig.types.json",
|
|
30
30
|
"clean": "rm -rf dist",
|
|
31
|
-
"lint": "npx eslint ./src
|
|
32
|
-
"lint:fix": "npx eslint ./src --
|
|
31
|
+
"lint": "npx eslint ./src",
|
|
32
|
+
"lint:fix": "npx eslint ./src --fix",
|
|
33
33
|
"prepare": "husky",
|
|
34
34
|
"prettier": "npx prettier . --write",
|
|
35
35
|
"test": "vitest --watch false",
|
|
@@ -40,21 +40,27 @@
|
|
|
40
40
|
"decimal.js": "^10.4.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"eslint
|
|
51
|
-
"eslint-
|
|
43
|
+
"@commitlint/cli": "^20.4.1",
|
|
44
|
+
"@commitlint/config-conventional": "^20.4.1",
|
|
45
|
+
"@eslint/js": "^9.39.2",
|
|
46
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
47
|
+
"@semantic-release/git": "^10.0.1",
|
|
48
|
+
"@types/node": "^22.19.8",
|
|
49
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
50
|
+
"eslint": "^9.39.2",
|
|
51
|
+
"eslint-config-prettier": "^10.1.8",
|
|
52
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
53
|
+
"eslint-plugin-import-x": "^4.16.1",
|
|
54
|
+
"globals": "^17.3.0",
|
|
52
55
|
"husky": "^9.0.11",
|
|
53
56
|
"prettier": "^3.3.2",
|
|
54
57
|
"prettier-eslint": "^16.3.0",
|
|
55
|
-
"prettier-plugin-packagejson": "^
|
|
58
|
+
"prettier-plugin-packagejson": "^3.0.0",
|
|
59
|
+
"semantic-release": "^25.0.3",
|
|
60
|
+
"tsc-alias": "^1.8.16",
|
|
56
61
|
"typescript": "^5.1.6",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
62
|
+
"typescript-eslint": "^8.54.0",
|
|
63
|
+
"vite-tsconfig-paths": "^6.0.5",
|
|
64
|
+
"vitest": "^4.0.18"
|
|
59
65
|
}
|
|
60
66
|
}
|