pimath 0.0.120 → 0.0.122
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/.idea/PI.iml +7 -1
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +90 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]1/shelved.patch +107 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +4 -0
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_1.xml +4 -0
- package/LICENSE.md +1 -1
- package/dev/pimath.js +7929 -0
- package/dev/pimath.js.map +1 -0
- package/dist/{pi.js → pimath.js} +7613 -7840
- package/dist/pimath.js.map +1 -0
- package/dist/pimath.min.js +2 -0
- package/dist/pimath.min.js.map +1 -0
- package/docs/assets/main.js +58 -58
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +1367 -1280
- package/docs/classes/Logicalset.Logicalset.html +221 -212
- package/docs/classes/Polynom.Rational.html +391 -388
- package/docs/classes/Vector-1.Vector.html +494 -448
- package/docs/classes/Vector.Point.html +341 -342
- package/docs/classes/algebra_equation.Equation.html +796 -753
- package/docs/classes/algebra_linearSystem.LinearSystem.html +408 -397
- package/docs/classes/algebra_monom.Monom.html +967 -910
- package/docs/classes/algebra_polynom.Polynom.html +1281 -1260
- package/docs/classes/coefficients_fraction.Fraction.html +939 -931
- package/docs/classes/geometry_circle.Circle.html +476 -476
- package/docs/classes/geometry_line.Line.html +779 -719
- package/docs/classes/geometry_triangle.Triangle.html +429 -420
- package/docs/classes/numeric.Numeric.html +269 -263
- package/docs/classes/shutingyard.Shutingyard.html +259 -248
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +89 -88
- package/docs/enums/geometry_line.LinePropriety.html +102 -102
- package/docs/enums/shutingyard.ShutingyardMode.html +106 -102
- package/docs/enums/shutingyard.ShutingyardType.html +120 -116
- package/docs/index.html +63 -65
- package/docs/interfaces/algebra_equation.ISolution.html +111 -109
- package/docs/interfaces/algebra_polynom.IEuclidian.html +93 -92
- package/docs/interfaces/geometry_triangle.remarquableLines.html +150 -150
- package/docs/modules/Logicalset.html +69 -74
- package/docs/modules/Polynom.html +69 -74
- package/docs/modules/Vector-1.html +69 -74
- package/docs/modules/Vector.html +69 -74
- package/docs/modules/algebra_equation.html +75 -81
- package/docs/modules/algebra_linearSystem.html +65 -71
- package/docs/modules/algebra_monom.html +70 -76
- package/docs/modules/algebra_polynom.html +75 -81
- package/docs/modules/coefficients_fraction.html +70 -76
- package/docs/modules/geometry_circle.html +65 -71
- package/docs/modules/geometry_line.html +70 -76
- package/docs/modules/geometry_triangle.html +70 -76
- package/docs/modules/numeric.html +65 -71
- package/docs/modules/shutingyard.html +84 -90
- package/docs/types/algebra_monom.literalType.html +66 -70
- package/docs/types/algebra_polynom.PolynomParsingType.html +62 -66
- package/docs/types/coefficients_fraction.FractionParsingType.html +61 -65
- package/docs/types/shutingyard.Token.html +72 -76
- package/docs/types/shutingyard.tokenType.html +77 -81
- package/docs/variables/shutingyard.tokenConstant.html +70 -74
- package/esm/index.d.ts +38 -41
- package/esm/index.js +43 -46
- package/esm/index.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +119 -117
- package/esm/maths/algebra/equation.js +796 -785
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +39 -38
- package/esm/maths/algebra/linearSystem.js +278 -262
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.d.ts +28 -28
- package/esm/maths/algebra/logicalset.js +157 -157
- package/esm/maths/algebra/monom.d.ts +206 -206
- package/esm/maths/algebra/monom.js +908 -908
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +157 -157
- package/esm/maths/algebra/polynom.js +1277 -1277
- package/esm/maths/algebra/rational.d.ts +45 -45
- package/esm/maths/algebra/rational.js +183 -183
- package/esm/maths/algebra/study/rationalStudy.d.ts +28 -28
- package/esm/maths/algebra/study/rationalStudy.js +243 -243
- package/esm/maths/algebra/study.d.ts +143 -142
- package/esm/maths/algebra/study.js +378 -377
- package/esm/maths/algebra/study.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +90 -90
- package/esm/maths/coefficients/fraction.js +516 -516
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/nthRoot.d.ts +23 -23
- package/esm/maths/coefficients/nthRoot.js +136 -136
- package/esm/maths/geometry/circle.d.ts +45 -45
- package/esm/maths/geometry/circle.js +323 -323
- package/esm/maths/geometry/line.d.ts +99 -99
- package/esm/maths/geometry/line.js +481 -481
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +34 -34
- package/esm/maths/geometry/point.js +166 -166
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +85 -85
- package/esm/maths/geometry/triangle.js +268 -268
- package/esm/maths/geometry/vector.d.ts +41 -41
- package/esm/maths/geometry/vector.js +197 -197
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/numeric.d.ts +28 -28
- package/esm/maths/numeric.js +180 -180
- package/esm/maths/numexp.d.ts +19 -0
- package/esm/maths/numexp.js +186 -0
- package/esm/maths/numexp.js.map +1 -0
- package/esm/maths/randomization/random.d.ts +23 -23
- package/esm/maths/randomization/random.js +78 -78
- package/esm/maths/randomization/random.js.map +1 -1
- package/esm/maths/randomization/randomCore.d.ts +7 -7
- package/esm/maths/randomization/randomCore.js +21 -21
- package/esm/maths/randomization/rndFraction.d.ts +12 -12
- package/esm/maths/randomization/rndFraction.js +43 -43
- package/esm/maths/randomization/rndGeometryLine.d.ts +12 -12
- package/esm/maths/randomization/rndGeometryLine.js +45 -45
- package/esm/maths/randomization/rndGeometryPoint.d.ts +12 -12
- package/esm/maths/randomization/rndGeometryPoint.js +60 -60
- package/esm/maths/randomization/rndHelpers.d.ts +23 -23
- package/esm/maths/randomization/rndHelpers.js +76 -76
- package/esm/maths/randomization/rndMonom.d.ts +12 -12
- package/esm/maths/randomization/rndMonom.js +52 -52
- package/esm/maths/randomization/rndPolynom.d.ts +13 -13
- package/esm/maths/randomization/rndPolynom.js +74 -74
- package/esm/maths/randomization/rndTypes.d.ts +34 -34
- package/esm/maths/randomization/rndTypes.js +2 -2
- package/esm/maths/shutingyard.d.ts +59 -59
- package/esm/maths/shutingyard.js +442 -442
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +11 -11
- package/public/index.html +50 -81
- package/public/playground.html +7 -8
- package/src/index.ts +1 -4
- package/src/maths/algebra/equation.ts +16 -0
- package/src/maths/algebra/linearSystem.ts +20 -0
- package/src/maths/algebra/study.ts +12 -10
- package/src/maths/{expressions/numexp.ts → numexp.ts} +2 -2
- package/tests/algebra/equation.test.ts +19 -5
- package/tests/algebra/linear.test.ts +3 -11
- package/tests/algebra/polynom.test.ts +7 -8
- package/tests/algebra/rationnal.test.ts +1 -1
- package/tests/algebra/study.test.ts +2 -9
- package/tests/coefficients/fraction.test.ts +8 -8
- package/tests/custom.test.ts +33 -37
- package/tests/numeric.test.ts +1 -2
- package/tests/numexp.test.ts +13 -5
- package/tests/shutingyard.test.ts +3 -3
- package/webpack-production-min.config.js +1 -1
- package/webpack-production.config.js +1 -1
- package/webpack.config.js +1 -1
- package/dist/pi.js.map +0 -1
- package/dist/pi.min.js +0 -2
- package/dist/pi.min.js.map +0 -1
- package/docs/classes/expressions_numexp.NumExp.html +0 -236
- package/docs/classes/expressions_polynomexp.PolynomExpFactor.html +0 -317
- package/docs/classes/expressions_polynomexp.PolynomExpProduct.html +0 -285
- package/docs/modules/expressions_numexp.html +0 -71
- package/docs/modules/expressions_polynomexp.html +0 -73
- package/docs/modules.html +0 -76
- package/graph.svg +0 -1033
- package/src/maths/expressions/ExpressionTree.ts +0 -172
- package/src/maths/expressions/expression.ts +0 -286
- package/src/maths/expressions/expressionFactor.ts +0 -190
- package/src/maths/expressions/expressionMember.ts +0 -233
- package/src/maths/expressions/expressionOperators.ts +0 -49
- package/src/maths/expressions/expressionParser.ts +0 -295
- package/src/maths/expressions/factors/ExpFactor.ts +0 -39
- package/src/maths/expressions/factors/ExpFactorConstant.ts +0 -60
- package/src/maths/expressions/factors/ExpFactorExponential.ts +0 -26
- package/src/maths/expressions/factors/ExpFactorNumber.ts +0 -72
- package/src/maths/expressions/factors/ExpFactorPower.ts +0 -42
- package/src/maths/expressions/factors/ExpFactorTrigo.ts +0 -53
- package/src/maths/expressions/factors/ExpFactorVariable.ts +0 -45
- package/src/maths/expressions/internals.ts +0 -14
- package/src/maths/expressions/polynomexp.bkp.ts +0 -221
- package/src/maths/expressions/polynomexp.ts +0 -310
- package/tests/expressions/expressions.test.ts +0 -145
- package/tests/expressions/expressiontree.test.ts +0 -11
- package/tests/polynomexp.test.ts +0 -12
|
@@ -1,198 +1,198 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Vector = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Vector module contains everything necessary to handle 2d or 3d vectors.
|
|
6
|
-
* @module Vector
|
|
7
|
-
*/
|
|
8
|
-
const fraction_1 = require("../coefficients/fraction");
|
|
9
|
-
const numeric_1 = require("../numeric");
|
|
10
|
-
const point_1 = require("./point");
|
|
11
|
-
class Vector {
|
|
12
|
-
constructor(...values) {
|
|
13
|
-
// ------------------------------------------
|
|
14
|
-
// Creation / parsing functions
|
|
15
|
-
// ------------------------------------------
|
|
16
|
-
this.parse = (...values) => {
|
|
17
|
-
// TODO: Must be more strict about what is given and limit to two dimensional vectors.p
|
|
18
|
-
// Maybe more than one value was given...
|
|
19
|
-
// Initialize the vector
|
|
20
|
-
this.zero();
|
|
21
|
-
if (values.length === 0) {
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
if (values.length === 1) {
|
|
25
|
-
if (values[0] instanceof Vector) {
|
|
26
|
-
return values[0].clone();
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
return this._parseString(values[0]);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (values.length >= 2) {
|
|
33
|
-
// Two points are given - skip the third value.
|
|
34
|
-
if (values[0] instanceof point_1.Point && values[1] instanceof point_1.Point) {
|
|
35
|
-
this._x = values[1].x.clone().subtract(values[0].x);
|
|
36
|
-
this._y = values[1].y.clone().subtract(values[0].y);
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
// Fractions or a number are give
|
|
40
|
-
if (values[0] instanceof fraction_1.Fraction || !isNaN(values[0])) {
|
|
41
|
-
this._x = new fraction_1.Fraction(values[0]);
|
|
42
|
-
}
|
|
43
|
-
if (values[1] instanceof fraction_1.Fraction || !isNaN(values[1])) {
|
|
44
|
-
this._y = new fraction_1.Fraction(values[1]);
|
|
45
|
-
}
|
|
46
|
-
if ((typeof values[0] === 'object' && !isNaN(values[0].x) && !isNaN(values[0].x)) &&
|
|
47
|
-
(typeof values[1] === 'object' && !isNaN(values[1].x) && !isNaN(values[1].x))) {
|
|
48
|
-
this._x = new fraction_1.Fraction(+values[1].x - values[0].x);
|
|
49
|
-
this._y = new fraction_1.Fraction(+values[1].y - values[0].y);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return this;
|
|
53
|
-
};
|
|
54
|
-
this.clone = () => {
|
|
55
|
-
let V = new Vector();
|
|
56
|
-
if (this._x !== null) {
|
|
57
|
-
V.x = this._x.clone();
|
|
58
|
-
}
|
|
59
|
-
if (this._y !== null) {
|
|
60
|
-
V.y = this._y.clone();
|
|
61
|
-
}
|
|
62
|
-
return V;
|
|
63
|
-
};
|
|
64
|
-
this.reset = () => {
|
|
65
|
-
this._x = null;
|
|
66
|
-
this._y = null;
|
|
67
|
-
return this;
|
|
68
|
-
};
|
|
69
|
-
this.zero = () => {
|
|
70
|
-
this.reset();
|
|
71
|
-
this._x = new fraction_1.Fraction(null);
|
|
72
|
-
this._y = new fraction_1.Fraction(null);
|
|
73
|
-
return this;
|
|
74
|
-
};
|
|
75
|
-
this.one = () => {
|
|
76
|
-
this._x = new fraction_1.Fraction();
|
|
77
|
-
this._y = new fraction_1.Fraction();
|
|
78
|
-
return this;
|
|
79
|
-
};
|
|
80
|
-
this._parseString = (value) => {
|
|
81
|
-
// Split comma, semi colon or single space.
|
|
82
|
-
let components = value.split(/[,;\s]/g);
|
|
83
|
-
// Validate the fraction values.
|
|
84
|
-
this.x = new fraction_1.Fraction(components[0] || null);
|
|
85
|
-
this.y = new fraction_1.Fraction(components[1] || null);
|
|
86
|
-
return this;
|
|
87
|
-
};
|
|
88
|
-
// ------------------------------------------
|
|
89
|
-
// Mathematical operations
|
|
90
|
-
// ------------------------------------------
|
|
91
|
-
this.opposed = () => {
|
|
92
|
-
this._x.opposed();
|
|
93
|
-
this._y.opposed();
|
|
94
|
-
return this;
|
|
95
|
-
};
|
|
96
|
-
this.add = (V) => {
|
|
97
|
-
this._x.add(V.x);
|
|
98
|
-
this._y.add(V.y);
|
|
99
|
-
return this;
|
|
100
|
-
};
|
|
101
|
-
this.subtract = (V) => {
|
|
102
|
-
return this.add(V.clone().opposed());
|
|
103
|
-
};
|
|
104
|
-
this.scalarProductWithVector = (V) => {
|
|
105
|
-
return Vector.scalarProduct(this, V);
|
|
106
|
-
// return this._x.clone().multiply(V.x).add(this._y.clone().multiply(V.y));
|
|
107
|
-
};
|
|
108
|
-
this.determinantWithVector = (V) => {
|
|
109
|
-
return Vector.determinant(this, V);
|
|
110
|
-
};
|
|
111
|
-
this.normal = () => {
|
|
112
|
-
let x = this.x.clone().opposed(), y = this.y.clone();
|
|
113
|
-
this._x = y;
|
|
114
|
-
this._y = x;
|
|
115
|
-
return this;
|
|
116
|
-
};
|
|
117
|
-
this.isColinearTo = (v) => {
|
|
118
|
-
return this.determinantWithVector(v).isZero();
|
|
119
|
-
};
|
|
120
|
-
this.isNormalTo = (v) => {
|
|
121
|
-
return this.scalarProductWithVector(v).isZero();
|
|
122
|
-
};
|
|
123
|
-
this.multiplyByScalar = (k) => {
|
|
124
|
-
let scalar = new fraction_1.Fraction(k);
|
|
125
|
-
this._x.multiply(scalar);
|
|
126
|
-
this._y.multiply(scalar);
|
|
127
|
-
return this;
|
|
128
|
-
};
|
|
129
|
-
this.divideByScalar = (k) => {
|
|
130
|
-
return this.multiplyByScalar(new fraction_1.Fraction(k).invert());
|
|
131
|
-
};
|
|
132
|
-
// ------------------------------------------
|
|
133
|
-
// Vector functions
|
|
134
|
-
// ------------------------------------------
|
|
135
|
-
this.simplify = () => {
|
|
136
|
-
// Multiply by the lcm of denominators.
|
|
137
|
-
return this.multiplyByScalar(numeric_1.Numeric.lcm(this._x.denominator, this._y.denominator))
|
|
138
|
-
.divideByScalar(numeric_1.Numeric.gcd(this._x.numerator, this._y.numerator));
|
|
139
|
-
};
|
|
140
|
-
this.simplifyDirection = () => {
|
|
141
|
-
let lcm = numeric_1.Numeric.lcm(this.x.denominator, this.y.denominator), gcd = numeric_1.Numeric.gcd(this.x.numerator, this.y.numerator);
|
|
142
|
-
this.x.multiply(lcm).divide(gcd);
|
|
143
|
-
this.y.multiply(lcm).divide(gcd);
|
|
144
|
-
return this;
|
|
145
|
-
};
|
|
146
|
-
this.angleWith = (V, sharp, radian) => {
|
|
147
|
-
let scalar = this.scalarProductWithVector(V).value, toDegree = radian ? 1 : 180 / Math.PI;
|
|
148
|
-
if (sharp) {
|
|
149
|
-
scalar = Math.abs(scalar);
|
|
150
|
-
}
|
|
151
|
-
return toDegree * Math.acos(scalar / (this.norm * V.norm));
|
|
152
|
-
};
|
|
153
|
-
this._x = new fraction_1.Fraction().zero();
|
|
154
|
-
this._y = new fraction_1.Fraction().zero();
|
|
155
|
-
if (values !== undefined) {
|
|
156
|
-
this.parse(...values);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
;
|
|
160
|
-
// ------------------------------------------
|
|
161
|
-
// Getter and setter
|
|
162
|
-
// ------------------------------------------
|
|
163
|
-
get x() {
|
|
164
|
-
return this._x;
|
|
165
|
-
}
|
|
166
|
-
set x(value) {
|
|
167
|
-
this._x = new fraction_1.Fraction(value);
|
|
168
|
-
}
|
|
169
|
-
get y() {
|
|
170
|
-
return this._y;
|
|
171
|
-
}
|
|
172
|
-
set y(value) {
|
|
173
|
-
this._y = new fraction_1.Fraction(value);
|
|
174
|
-
}
|
|
175
|
-
get normSquare() {
|
|
176
|
-
return this._x.clone().pow(2).add(this._y.clone().pow(2));
|
|
177
|
-
}
|
|
178
|
-
get norm() {
|
|
179
|
-
return Math.sqrt(this.normSquare.value);
|
|
180
|
-
}
|
|
181
|
-
get tex() {
|
|
182
|
-
return `\\begin{pmatrix}${this._x.tex} \\\\\ ${this._y.tex} \\end{pmatrix}`;
|
|
183
|
-
}
|
|
184
|
-
get asPoint() {
|
|
185
|
-
return new point_1.Point(this.x, this.y);
|
|
186
|
-
}
|
|
187
|
-
get isNull() {
|
|
188
|
-
return this.x.isZero() && this.y.isZero();
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
exports.Vector = Vector;
|
|
192
|
-
Vector.scalarProduct = (v1, v2) => {
|
|
193
|
-
return v1.x.clone().multiply(v2.x).add(v1.y.clone().multiply(v2.y));
|
|
194
|
-
};
|
|
195
|
-
Vector.determinant = (v1, v2) => {
|
|
196
|
-
return v1.x.clone().multiply(v2.y).subtract(v1.y.clone().multiply(v2.x));
|
|
197
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Vector = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Vector module contains everything necessary to handle 2d or 3d vectors.
|
|
6
|
+
* @module Vector
|
|
7
|
+
*/
|
|
8
|
+
const fraction_1 = require("../coefficients/fraction");
|
|
9
|
+
const numeric_1 = require("../numeric");
|
|
10
|
+
const point_1 = require("./point");
|
|
11
|
+
class Vector {
|
|
12
|
+
constructor(...values) {
|
|
13
|
+
// ------------------------------------------
|
|
14
|
+
// Creation / parsing functions
|
|
15
|
+
// ------------------------------------------
|
|
16
|
+
this.parse = (...values) => {
|
|
17
|
+
// TODO: Must be more strict about what is given and limit to two dimensional vectors.p
|
|
18
|
+
// Maybe more than one value was given...
|
|
19
|
+
// Initialize the vector
|
|
20
|
+
this.zero();
|
|
21
|
+
if (values.length === 0) {
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
if (values.length === 1) {
|
|
25
|
+
if (values[0] instanceof Vector) {
|
|
26
|
+
return values[0].clone();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return this._parseString(values[0]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (values.length >= 2) {
|
|
33
|
+
// Two points are given - skip the third value.
|
|
34
|
+
if (values[0] instanceof point_1.Point && values[1] instanceof point_1.Point) {
|
|
35
|
+
this._x = values[1].x.clone().subtract(values[0].x);
|
|
36
|
+
this._y = values[1].y.clone().subtract(values[0].y);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
// Fractions or a number are give
|
|
40
|
+
if (values[0] instanceof fraction_1.Fraction || !isNaN(values[0])) {
|
|
41
|
+
this._x = new fraction_1.Fraction(values[0]);
|
|
42
|
+
}
|
|
43
|
+
if (values[1] instanceof fraction_1.Fraction || !isNaN(values[1])) {
|
|
44
|
+
this._y = new fraction_1.Fraction(values[1]);
|
|
45
|
+
}
|
|
46
|
+
if ((typeof values[0] === 'object' && !isNaN(values[0].x) && !isNaN(values[0].x)) &&
|
|
47
|
+
(typeof values[1] === 'object' && !isNaN(values[1].x) && !isNaN(values[1].x))) {
|
|
48
|
+
this._x = new fraction_1.Fraction(+values[1].x - values[0].x);
|
|
49
|
+
this._y = new fraction_1.Fraction(+values[1].y - values[0].y);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return this;
|
|
53
|
+
};
|
|
54
|
+
this.clone = () => {
|
|
55
|
+
let V = new Vector();
|
|
56
|
+
if (this._x !== null) {
|
|
57
|
+
V.x = this._x.clone();
|
|
58
|
+
}
|
|
59
|
+
if (this._y !== null) {
|
|
60
|
+
V.y = this._y.clone();
|
|
61
|
+
}
|
|
62
|
+
return V;
|
|
63
|
+
};
|
|
64
|
+
this.reset = () => {
|
|
65
|
+
this._x = null;
|
|
66
|
+
this._y = null;
|
|
67
|
+
return this;
|
|
68
|
+
};
|
|
69
|
+
this.zero = () => {
|
|
70
|
+
this.reset();
|
|
71
|
+
this._x = new fraction_1.Fraction(null);
|
|
72
|
+
this._y = new fraction_1.Fraction(null);
|
|
73
|
+
return this;
|
|
74
|
+
};
|
|
75
|
+
this.one = () => {
|
|
76
|
+
this._x = new fraction_1.Fraction();
|
|
77
|
+
this._y = new fraction_1.Fraction();
|
|
78
|
+
return this;
|
|
79
|
+
};
|
|
80
|
+
this._parseString = (value) => {
|
|
81
|
+
// Split comma, semi colon or single space.
|
|
82
|
+
let components = value.split(/[,;\s]/g);
|
|
83
|
+
// Validate the fraction values.
|
|
84
|
+
this.x = new fraction_1.Fraction(components[0] || null);
|
|
85
|
+
this.y = new fraction_1.Fraction(components[1] || null);
|
|
86
|
+
return this;
|
|
87
|
+
};
|
|
88
|
+
// ------------------------------------------
|
|
89
|
+
// Mathematical operations
|
|
90
|
+
// ------------------------------------------
|
|
91
|
+
this.opposed = () => {
|
|
92
|
+
this._x.opposed();
|
|
93
|
+
this._y.opposed();
|
|
94
|
+
return this;
|
|
95
|
+
};
|
|
96
|
+
this.add = (V) => {
|
|
97
|
+
this._x.add(V.x);
|
|
98
|
+
this._y.add(V.y);
|
|
99
|
+
return this;
|
|
100
|
+
};
|
|
101
|
+
this.subtract = (V) => {
|
|
102
|
+
return this.add(V.clone().opposed());
|
|
103
|
+
};
|
|
104
|
+
this.scalarProductWithVector = (V) => {
|
|
105
|
+
return Vector.scalarProduct(this, V);
|
|
106
|
+
// return this._x.clone().multiply(V.x).add(this._y.clone().multiply(V.y));
|
|
107
|
+
};
|
|
108
|
+
this.determinantWithVector = (V) => {
|
|
109
|
+
return Vector.determinant(this, V);
|
|
110
|
+
};
|
|
111
|
+
this.normal = () => {
|
|
112
|
+
let x = this.x.clone().opposed(), y = this.y.clone();
|
|
113
|
+
this._x = y;
|
|
114
|
+
this._y = x;
|
|
115
|
+
return this;
|
|
116
|
+
};
|
|
117
|
+
this.isColinearTo = (v) => {
|
|
118
|
+
return this.determinantWithVector(v).isZero();
|
|
119
|
+
};
|
|
120
|
+
this.isNormalTo = (v) => {
|
|
121
|
+
return this.scalarProductWithVector(v).isZero();
|
|
122
|
+
};
|
|
123
|
+
this.multiplyByScalar = (k) => {
|
|
124
|
+
let scalar = new fraction_1.Fraction(k);
|
|
125
|
+
this._x.multiply(scalar);
|
|
126
|
+
this._y.multiply(scalar);
|
|
127
|
+
return this;
|
|
128
|
+
};
|
|
129
|
+
this.divideByScalar = (k) => {
|
|
130
|
+
return this.multiplyByScalar(new fraction_1.Fraction(k).invert());
|
|
131
|
+
};
|
|
132
|
+
// ------------------------------------------
|
|
133
|
+
// Vector functions
|
|
134
|
+
// ------------------------------------------
|
|
135
|
+
this.simplify = () => {
|
|
136
|
+
// Multiply by the lcm of denominators.
|
|
137
|
+
return this.multiplyByScalar(numeric_1.Numeric.lcm(this._x.denominator, this._y.denominator))
|
|
138
|
+
.divideByScalar(numeric_1.Numeric.gcd(this._x.numerator, this._y.numerator));
|
|
139
|
+
};
|
|
140
|
+
this.simplifyDirection = () => {
|
|
141
|
+
let lcm = numeric_1.Numeric.lcm(this.x.denominator, this.y.denominator), gcd = numeric_1.Numeric.gcd(this.x.numerator, this.y.numerator);
|
|
142
|
+
this.x.multiply(lcm).divide(gcd);
|
|
143
|
+
this.y.multiply(lcm).divide(gcd);
|
|
144
|
+
return this;
|
|
145
|
+
};
|
|
146
|
+
this.angleWith = (V, sharp, radian) => {
|
|
147
|
+
let scalar = this.scalarProductWithVector(V).value, toDegree = radian ? 1 : 180 / Math.PI;
|
|
148
|
+
if (sharp) {
|
|
149
|
+
scalar = Math.abs(scalar);
|
|
150
|
+
}
|
|
151
|
+
return toDegree * Math.acos(scalar / (this.norm * V.norm));
|
|
152
|
+
};
|
|
153
|
+
this._x = new fraction_1.Fraction().zero();
|
|
154
|
+
this._y = new fraction_1.Fraction().zero();
|
|
155
|
+
if (values !== undefined) {
|
|
156
|
+
this.parse(...values);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
;
|
|
160
|
+
// ------------------------------------------
|
|
161
|
+
// Getter and setter
|
|
162
|
+
// ------------------------------------------
|
|
163
|
+
get x() {
|
|
164
|
+
return this._x;
|
|
165
|
+
}
|
|
166
|
+
set x(value) {
|
|
167
|
+
this._x = new fraction_1.Fraction(value);
|
|
168
|
+
}
|
|
169
|
+
get y() {
|
|
170
|
+
return this._y;
|
|
171
|
+
}
|
|
172
|
+
set y(value) {
|
|
173
|
+
this._y = new fraction_1.Fraction(value);
|
|
174
|
+
}
|
|
175
|
+
get normSquare() {
|
|
176
|
+
return this._x.clone().pow(2).add(this._y.clone().pow(2));
|
|
177
|
+
}
|
|
178
|
+
get norm() {
|
|
179
|
+
return Math.sqrt(this.normSquare.value);
|
|
180
|
+
}
|
|
181
|
+
get tex() {
|
|
182
|
+
return `\\begin{pmatrix}${this._x.tex} \\\\\ ${this._y.tex} \\end{pmatrix}`;
|
|
183
|
+
}
|
|
184
|
+
get asPoint() {
|
|
185
|
+
return new point_1.Point(this.x, this.y);
|
|
186
|
+
}
|
|
187
|
+
get isNull() {
|
|
188
|
+
return this.x.isZero() && this.y.isZero();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.Vector = Vector;
|
|
192
|
+
Vector.scalarProduct = (v1, v2) => {
|
|
193
|
+
return v1.x.clone().multiply(v2.x).add(v1.y.clone().multiply(v2.y));
|
|
194
|
+
};
|
|
195
|
+
Vector.determinant = (v1, v2) => {
|
|
196
|
+
return v1.x.clone().multiply(v2.y).subtract(v1.y.clone().multiply(v2.x));
|
|
197
|
+
};
|
|
198
198
|
//# sourceMappingURL=vector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.js","sourceRoot":"","sources":["../../../src/maths/geometry/vector.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uDAAkD;AAClD,wCAAmC;AACnC,mCAA8B;AAE9B,MAAa,MAAM;IAIf,YAAY,GAAG,MAAiB;QA4ChC,6CAA6C;QAC7C,+BAA+B;QAC/B,6CAA6C;QAE7C,UAAK,GAAG,CAAC,GAAG,MAAW,EAAU,EAAE;YAC/B,uFAAuF;YACvF,yCAAyC;YACzC,wBAAwB;YACxB,IAAI,CAAC,IAAI,EAAE,CAAC;YAEZ,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;gBACrB,OAAO,IAAI,CAAC;aACf;YAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;gBACrB,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,MAAM,EAAE;oBAC7B,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;iBAC3B;qBAAM;oBACH,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;iBACtC;aACJ;YAED,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC,EAAE;gBACpB,+CAA+C;gBAC/C,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,aAAK,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,aAAK,EAAE;oBAC1D,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;oBACnD,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CA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AACxE,CAAC,AAFmB,CAElB;AAEK,kBAAW,GAAG,CAAC,EAAU,EAAE,EAAU,EAAY,EAAE;IACtD,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;AAC5E,CAAC,AAFiB,CAEjB"}
|
package/esm/maths/numeric.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
export declare class Numeric {
|
|
2
|
-
static round(value: number, decimals?: number): number;
|
|
3
|
-
/**
|
|
4
|
-
* Get the list of the nth first prime numbers.
|
|
5
|
-
* @param nb : number of primes to choose from
|
|
6
|
-
*/
|
|
7
|
-
static primes(nb?: number): number[];
|
|
8
|
-
/**
|
|
9
|
-
* Get the list of all dividers of a number.
|
|
10
|
-
* @param value
|
|
11
|
-
*/
|
|
12
|
-
static dividers(value: number): number[];
|
|
13
|
-
/**
|
|
14
|
-
* Great Common Divisor
|
|
15
|
-
* @param values : number values
|
|
16
|
-
*/
|
|
17
|
-
static gcd(...values: number[]): number;
|
|
18
|
-
static divideNumbersByGCD(...values: number[]): number[];
|
|
19
|
-
/**
|
|
20
|
-
* Least Common Multiple
|
|
21
|
-
* @param values: list of numbers
|
|
22
|
-
*/
|
|
23
|
-
static lcm(...values: number[]): number;
|
|
24
|
-
static pythagoricianTripletsWithTarget(target: number, targetIsSquare?: boolean): number[][];
|
|
25
|
-
static numberCorrection(value: number, epsilonDigit?: number, epsilonNumberOfDigits?: number, number_of_digits?: number): number;
|
|
26
|
-
static periodic(value: number): number;
|
|
27
|
-
static decompose(value: number): number[][];
|
|
28
|
-
}
|
|
1
|
+
export declare class Numeric {
|
|
2
|
+
static round(value: number, decimals?: number): number;
|
|
3
|
+
/**
|
|
4
|
+
* Get the list of the nth first prime numbers.
|
|
5
|
+
* @param nb : number of primes to choose from
|
|
6
|
+
*/
|
|
7
|
+
static primes(nb?: number): number[];
|
|
8
|
+
/**
|
|
9
|
+
* Get the list of all dividers of a number.
|
|
10
|
+
* @param value
|
|
11
|
+
*/
|
|
12
|
+
static dividers(value: number): number[];
|
|
13
|
+
/**
|
|
14
|
+
* Great Common Divisor
|
|
15
|
+
* @param values : number values
|
|
16
|
+
*/
|
|
17
|
+
static gcd(...values: number[]): number;
|
|
18
|
+
static divideNumbersByGCD(...values: number[]): number[];
|
|
19
|
+
/**
|
|
20
|
+
* Least Common Multiple
|
|
21
|
+
* @param values: list of numbers
|
|
22
|
+
*/
|
|
23
|
+
static lcm(...values: number[]): number;
|
|
24
|
+
static pythagoricianTripletsWithTarget(target: number, targetIsSquare?: boolean): number[][];
|
|
25
|
+
static numberCorrection(value: number, epsilonDigit?: number, epsilonNumberOfDigits?: number, number_of_digits?: number): number;
|
|
26
|
+
static periodic(value: number): number;
|
|
27
|
+
static decompose(value: number): number[][];
|
|
28
|
+
}
|