pimath 0.0.123 → 0.0.125
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/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +192 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]1/shelved.patch +0 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30__Default_Changelist_.xml +4 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +2404 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +4 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +1362 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +4 -0
- package/dist/pimath.js +53 -14
- package/dist/pimath.js.map +1 -1
- package/dist/pimath.min.js +1 -1
- package/dist/pimath.min.js.map +1 -1
- package/esm/maths/algebra/rational.d.ts +1 -0
- package/esm/maths/algebra/rational.js +12 -1
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +6 -0
- package/esm/maths/geometry/triangle.js +14 -7
- package/esm/maths/geometry/triangle.js.map +1 -1
- package/esm/maths/randomization/random.d.ts +1 -1
- package/esm/maths/randomization/random.js +2 -2
- package/esm/maths/randomization/random.js.map +1 -1
- package/esm/maths/randomization/rndHelpers.d.ts +1 -1
- package/esm/maths/randomization/rndHelpers.js +25 -4
- package/esm/maths/randomization/rndHelpers.js.map +1 -1
- package/package.json +8 -8
- package/src/maths/algebra/rational.ts +13 -1
- package/src/maths/geometry/triangle.ts +24 -8
- package/src/maths/randomization/random.ts +2 -2
- package/src/maths/randomization/rndHelpers.ts +49 -18
- package/tests/algebra/rationnal.test.ts +5 -0
- package/tests/geometry/circle.test.ts +125 -10
- package/tests/numexp.test.ts +15 -2
- package/dev/pimath.js +0 -7935
- package/dev/pimath.js.map +0 -1
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -78
- package/docs/assets/main.js +0 -58
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1367
- package/docs/classes/Logicalset.Logicalset.html +0 -221
- package/docs/classes/Polynom.Rational.html +0 -391
- package/docs/classes/Vector-1.Vector.html +0 -494
- package/docs/classes/Vector.Point.html +0 -341
- package/docs/classes/algebra_equation.Equation.html +0 -796
- package/docs/classes/algebra_linearSystem.LinearSystem.html +0 -408
- package/docs/classes/algebra_monom.Monom.html +0 -967
- package/docs/classes/algebra_polynom.Polynom.html +0 -1281
- package/docs/classes/coefficients_fraction.Fraction.html +0 -939
- package/docs/classes/geometry_circle.Circle.html +0 -476
- package/docs/classes/geometry_line.Line.html +0 -779
- package/docs/classes/geometry_triangle.Triangle.html +0 -429
- package/docs/classes/numeric.Numeric.html +0 -269
- package/docs/classes/shutingyard.Shutingyard.html +0 -259
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +0 -89
- package/docs/enums/geometry_line.LinePropriety.html +0 -102
- package/docs/enums/shutingyard.ShutingyardMode.html +0 -106
- package/docs/enums/shutingyard.ShutingyardType.html +0 -120
- package/docs/index.html +0 -63
- package/docs/interfaces/algebra_equation.ISolution.html +0 -111
- package/docs/interfaces/algebra_polynom.IEuclidian.html +0 -93
- package/docs/interfaces/geometry_triangle.remarquableLines.html +0 -150
- package/docs/modules/Logicalset.html +0 -69
- package/docs/modules/Polynom.html +0 -69
- package/docs/modules/Vector-1.html +0 -69
- package/docs/modules/Vector.html +0 -69
- package/docs/modules/algebra_equation.html +0 -75
- package/docs/modules/algebra_linearSystem.html +0 -65
- package/docs/modules/algebra_monom.html +0 -70
- package/docs/modules/algebra_polynom.html +0 -75
- package/docs/modules/coefficients_fraction.html +0 -70
- package/docs/modules/geometry_circle.html +0 -65
- package/docs/modules/geometry_line.html +0 -70
- package/docs/modules/geometry_triangle.html +0 -70
- package/docs/modules/numeric.html +0 -65
- package/docs/modules/shutingyard.html +0 -84
- package/docs/types/algebra_monom.literalType.html +0 -66
- package/docs/types/algebra_polynom.PolynomParsingType.html +0 -62
- package/docs/types/coefficients_fraction.FractionParsingType.html +0 -61
- package/docs/types/shutingyard.Token.html +0 -72
- package/docs/types/shutingyard.tokenType.html +0 -77
- package/docs/variables/shutingyard.tokenConstant.html +0 -70
- package/esm/maths/expressions/ExpressionTree.d.ts +0 -17
- package/esm/maths/expressions/ExpressionTree.js +0 -150
- package/esm/maths/expressions/ExpressionTree.js.map +0 -1
- package/esm/maths/expressions/expression.d.ts +0 -27
- package/esm/maths/expressions/expression.js +0 -239
- package/esm/maths/expressions/expression.js.map +0 -1
- package/esm/maths/expressions/expressionFactor.d.ts +0 -36
- package/esm/maths/expressions/expressionFactor.js +0 -156
- package/esm/maths/expressions/expressionFactor.js.map +0 -1
- package/esm/maths/expressions/expressionMember.d.ts +0 -27
- package/esm/maths/expressions/expressionMember.js +0 -199
- package/esm/maths/expressions/expressionMember.js.map +0 -1
- package/esm/maths/expressions/expressionOperators.d.ts +0 -8
- package/esm/maths/expressions/expressionOperators.js +0 -42
- package/esm/maths/expressions/expressionOperators.js.map +0 -1
- package/esm/maths/expressions/expressionParser.d.ts +0 -14
- package/esm/maths/expressions/expressionParser.js +0 -259
- package/esm/maths/expressions/expressionParser.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactor.d.ts +0 -7
- package/esm/maths/expressions/factors/ExpFactor.js +0 -34
- package/esm/maths/expressions/factors/ExpFactor.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorConstant.d.ts +0 -14
- package/esm/maths/expressions/factors/ExpFactorConstant.js +0 -52
- package/esm/maths/expressions/factors/ExpFactorConstant.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorExponential.d.ts +0 -8
- package/esm/maths/expressions/factors/ExpFactorExponential.js +0 -22
- package/esm/maths/expressions/factors/ExpFactorExponential.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorNumber.d.ts +0 -14
- package/esm/maths/expressions/factors/ExpFactorNumber.js +0 -59
- package/esm/maths/expressions/factors/ExpFactorNumber.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorPower.d.ts +0 -13
- package/esm/maths/expressions/factors/ExpFactorPower.js +0 -35
- package/esm/maths/expressions/factors/ExpFactorPower.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorTrigo.d.ts +0 -20
- package/esm/maths/expressions/factors/ExpFactorTrigo.js +0 -48
- package/esm/maths/expressions/factors/ExpFactorTrigo.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorVariable.d.ts +0 -13
- package/esm/maths/expressions/factors/ExpFactorVariable.js +0 -36
- package/esm/maths/expressions/factors/ExpFactorVariable.js.map +0 -1
- package/esm/maths/expressions/internals.d.ts +0 -12
- package/esm/maths/expressions/internals.js +0 -29
- package/esm/maths/expressions/internals.js.map +0 -1
- package/esm/maths/expressions/numexp.d.ts +0 -19
- package/esm/maths/expressions/numexp.js +0 -186
- package/esm/maths/expressions/numexp.js.map +0 -1
- package/esm/maths/expressions/polynomexp.bkp.d.ts +0 -33
- package/esm/maths/expressions/polynomexp.bkp.js +0 -184
- package/esm/maths/expressions/polynomexp.bkp.js.map +0 -1
- package/esm/maths/expressions/polynomexp.d.ts +0 -52
- package/esm/maths/expressions/polynomexp.js +0 -246
- package/esm/maths/expressions/polynomexp.js.map +0 -1
|
@@ -4,14 +4,16 @@ import {Circle} from "../../src/maths/geometry/circle";
|
|
|
4
4
|
import {Line} from "../../src/maths/geometry/line";
|
|
5
5
|
import {Point} from "../../src/maths/geometry/point";
|
|
6
6
|
import {Fraction} from "../../src/maths/coefficients/fraction";
|
|
7
|
+
import {Random} from "../../src/maths/randomization/random";
|
|
8
|
+
import {Numeric} from "../../src/maths/numeric";
|
|
7
9
|
|
|
8
10
|
describe('Circle', function () {
|
|
9
11
|
it('should calculate the intersection of a circle and a line', function () {
|
|
10
12
|
let C = new Circle(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
new Point(8, 6),
|
|
14
|
+
20,
|
|
15
|
+
true
|
|
16
|
+
),
|
|
15
17
|
LT = new Line('2x+y-32=0'),
|
|
16
18
|
LS = new Line('3x-y-8=0'),
|
|
17
19
|
IPT = C.lineIntersection(LT),
|
|
@@ -28,7 +30,7 @@ describe('Circle', function () {
|
|
|
28
30
|
expect(IPS[1].y.value).to.be.equal(10)
|
|
29
31
|
});
|
|
30
32
|
|
|
31
|
-
it('should calculate tangents', function(){
|
|
33
|
+
it('should calculate tangents', function () {
|
|
32
34
|
|
|
33
35
|
// Through one point on the circle
|
|
34
36
|
const C = new Circle(
|
|
@@ -37,18 +39,18 @@ describe('Circle', function () {
|
|
|
37
39
|
true
|
|
38
40
|
), P = new Point(-5, 7);
|
|
39
41
|
|
|
40
|
-
expect(C.tangents(P).map(x=>x.tex.canonical)).to.have.all.members(['3x-4y+43=0'])
|
|
42
|
+
expect(C.tangents(P).map(x => x.tex.canonical)).to.have.all.members(['3x-4y+43=0'])
|
|
41
43
|
|
|
42
44
|
// With a slope
|
|
43
45
|
const D = new Circle('x^2+y^2+10x=2y-6'),
|
|
44
46
|
slope = new Fraction(-2, 1)
|
|
45
47
|
|
|
46
|
-
expect(D.tangents(slope).map(x=>x.tex.canonical)).to.have.all.members(['2x+y-1=0', '2x+y+19=0'])
|
|
48
|
+
expect(D.tangents(slope).map(x => x.tex.canonical)).to.have.all.members(['2x+y-1=0', '2x+y+19=0'])
|
|
47
49
|
|
|
48
50
|
const E = new Circle('(x-2)^2+(y-1)^2=5'),
|
|
49
51
|
P2 = new Point(6, -2)
|
|
50
52
|
|
|
51
|
-
expect(E.tangents(P2).map(x=>x.tex.canonical)).to.have.all.members(['2x+y-10=0','2x+11y+10=0'])
|
|
53
|
+
expect(E.tangents(P2).map(x => x.tex.canonical)).to.have.all.members(['2x+y-10=0', '2x+11y+10=0'])
|
|
52
54
|
|
|
53
55
|
let P3 = new Point(2, 2)
|
|
54
56
|
expect(E.tangents(P3)).to.be.empty
|
|
@@ -58,10 +60,10 @@ describe('Circle', function () {
|
|
|
58
60
|
const C = new Circle('(x-3)^2+(y+4)^2=16'),
|
|
59
61
|
pts = C.getPointsOnCircle()
|
|
60
62
|
|
|
61
|
-
expect(pts.map(x=>x.x.display + ',' + x.y.display)).to.have.all.members([
|
|
63
|
+
expect(pts.map(x => x.x.display + ',' + x.y.display)).to.have.all.members(['3,0', '3,-8', '7,-4', '-1,-4'])
|
|
62
64
|
});
|
|
63
65
|
|
|
64
|
-
it('should calculate the circle from center and radius', function(){
|
|
66
|
+
it('should calculate the circle from center and radius', function () {
|
|
65
67
|
let circle = new Circle("x^2+6x+y^2-8y+12=0")
|
|
66
68
|
|
|
67
69
|
console.log(circle.tex)
|
|
@@ -81,4 +83,117 @@ describe('Circle', function () {
|
|
|
81
83
|
let L = new Line(A, B)
|
|
82
84
|
console.log(L.tex.canonical)
|
|
83
85
|
});
|
|
86
|
+
|
|
87
|
+
it('temp tests', () => {
|
|
88
|
+
for (let i = 0; i < 30; i++) {
|
|
89
|
+
let A = Random.Geometry.point({axis: false}),
|
|
90
|
+
B = Random.Geometry.point({axis: false})
|
|
91
|
+
|
|
92
|
+
if (Random.bool()) {
|
|
93
|
+
B.x = new Fraction().zero()
|
|
94
|
+
} else {
|
|
95
|
+
B.y = new Fraction().zero()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const c1 = new Circle(A, Random.number(1, 10)),
|
|
99
|
+
c2 = new Circle(B, Random.number(1, 10))
|
|
100
|
+
|
|
101
|
+
console.log(`(exercice ${i + 1}): déterminer la forme \\textbf{centre-rayon} des équations cartésiennes suivantes. En déduire le centre et le rayon du cercle.
|
|
102
|
+
\\begin{enumerate}[label=\\Alph*]
|
|
103
|
+
\\item \\( (\\Gamma_1): ${c1.developed}\\) \\iftoggle{master}{\\(${c1.tex}\\)}{}
|
|
104
|
+
\\item \\( (\\Gamma_2): ${c2.developed}\\) \\iftoggle{master}{\\(${c2.tex}\\)}{}
|
|
105
|
+
\\end{enumerate}
|
|
106
|
+
\\vfill
|
|
107
|
+
${i % 2 === 1 ? '\\newpage' : ''}
|
|
108
|
+
`)
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('temp tests 2', () => {
|
|
113
|
+
const q = `(I): Soit \\(\\Gamma_1\\) et \\(\\Gamma_2\\) deux cercles. Déterminer leur position relative à l'aide des informations ci-dessous.
|
|
114
|
+
|
|
115
|
+
\\[(\\Gamma_1): @G1 \\qquad (\\Gamma_2): @G2 \\]
|
|
116
|
+
\\[\\trou{@R1} \\]
|
|
117
|
+
|
|
118
|
+
\\vspace{3cm}
|
|
119
|
+
(II): Soit \\((\\Gamma_3): @G3\\) un cercle. Déterminer l'équation cartésienne, sous sa forme centre-sommet, des cercles \\(\\Gamma_4\\) de rayon \\(@RAYON\\) qui sont tangents à \\(\\Gamma_3\\) en sachant que les deux centres ont la même @AXE.\\\\
|
|
120
|
+
Préciser la position relative entre \\(\\Gamma_3\\) et \\(\\Gamma_4\\)
|
|
121
|
+
\\[ \\trou{@R2a} \\]
|
|
122
|
+
\\[ \\trou{@R2b} \\]
|
|
123
|
+
`
|
|
124
|
+
|
|
125
|
+
for (let i = 0; i < 30; i++) {
|
|
126
|
+
let A = Random.Geometry.point({axis: false}),
|
|
127
|
+
triplet = Random.item(Numeric.pythagoricianTripletsWithTarget(
|
|
128
|
+
Random.item([5, 13, 17, 25, 29, 37, 41])
|
|
129
|
+
).filter(tr => {
|
|
130
|
+
// remove all items with zero values.
|
|
131
|
+
return tr.every(x => x !== 0)
|
|
132
|
+
})),
|
|
133
|
+
B = new Point(
|
|
134
|
+
A.x.value + triplet[0],
|
|
135
|
+
A.y.value + triplet[1]
|
|
136
|
+
),
|
|
137
|
+
delta = Random.number(2, triplet[2] - 1),
|
|
138
|
+
positionRelative = ['extérieure', 'intérieure', 'sécante', 'disjointe'][i % 4],
|
|
139
|
+
// positionRelative = Random.item(['extérieure', 'intérieure', 'sécante', 'disjointe']),
|
|
140
|
+
c1: Circle, c2: Circle
|
|
141
|
+
|
|
142
|
+
if (positionRelative === 'extérieure') {
|
|
143
|
+
c1 = new Circle(A, triplet[2] - delta)
|
|
144
|
+
c2 = new Circle(B, delta)
|
|
145
|
+
} else if (positionRelative === 'intérieure') {
|
|
146
|
+
c1 = new Circle(A, triplet[2] + delta)
|
|
147
|
+
c2 = new Circle(B, delta)
|
|
148
|
+
} else if (positionRelative === 'sécante') {
|
|
149
|
+
c1 = new Circle(A, triplet[2] + delta - Random.number(1, delta - 1))
|
|
150
|
+
c2 = new Circle(B, delta)
|
|
151
|
+
} else if (positionRelative === 'disjointe') {
|
|
152
|
+
c1 = new Circle(A, triplet[2] + delta + 1)
|
|
153
|
+
c2 = new Circle(B, delta)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const R1 = `\\delta(O_1;O_2)=${A.distanceTo(B).value}\\qquad r_1=${c1.radius.value} \\qquad ${c2.radius.value} \\qquad \\implies \\text{${positionRelative}} `
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
let C = Random.Geometry.point({axis: false}),
|
|
160
|
+
r1 = Random.number(2, 10),
|
|
161
|
+
c3 = new Circle(C, r1),
|
|
162
|
+
// Get a random number from 2 to 10 that is not equal to r1
|
|
163
|
+
r2 = Random.number(2, 10, [r1]),
|
|
164
|
+
axis = Random.item(['abscisse', 'ordonnée']),
|
|
165
|
+
centers: Point[] = []
|
|
166
|
+
|
|
167
|
+
const c3x = c3.center.x.value,
|
|
168
|
+
c3y = c3.center.y.value
|
|
169
|
+
if (axis === 'abscisse') {
|
|
170
|
+
|
|
171
|
+
centers = [
|
|
172
|
+
new Point(c3x, c3y - (r1 + r2)),
|
|
173
|
+
new Point(c3x, c3y - (r2 - r1)),
|
|
174
|
+
new Point(c3x, c3y - (r1 - r2)),
|
|
175
|
+
new Point(c3x, c3y + (r1 + r2))
|
|
176
|
+
]
|
|
177
|
+
} else {
|
|
178
|
+
centers = [
|
|
179
|
+
new Point(c3x - (r1 + r2), c3y),
|
|
180
|
+
new Point(c3x - (r2 - r1), c3y),
|
|
181
|
+
new Point(c3x - (r1 - r2), c3y),
|
|
182
|
+
new Point(c3x + (r1 + r2), c3y)
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
console.log(`(exercice ${i + 1}): ` + q
|
|
187
|
+
.replaceAll('@G1', c1.tex)
|
|
188
|
+
.replaceAll('@R1', R1)
|
|
189
|
+
.replaceAll('@G2', c2.tex)
|
|
190
|
+
.replaceAll('@G3', c3.developed)
|
|
191
|
+
.replaceAll('@RAYON', r2.toString())
|
|
192
|
+
.replaceAll('@AXE', axis)
|
|
193
|
+
.replaceAll('@R2a', centers.slice(0, 2).map(x => new Circle(x, r2).tex).join(' \\qquad '))
|
|
194
|
+
.replaceAll('@R2b', centers.slice(2, 4).map(x => new Circle(x, r2).tex).join(' \\qquad '))
|
|
195
|
+
+ '\\vfill' + (i % 2 === 1 ? '\\newpage' : '')
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
})
|
|
84
199
|
});
|
package/tests/numexp.test.ts
CHANGED
|
@@ -31,7 +31,7 @@ describe('Numerical expression', () => { // the tests container
|
|
|
31
31
|
expect(exprInvalid.isValid).to.be.false
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
it('souldd detect invalid expression withouth crahsing', function() {
|
|
34
|
+
it('souldd detect invalid expression withouth crahsing', function () {
|
|
35
35
|
const exprPourrie = new NumExp('3xsi'),
|
|
36
36
|
exprOk = new NumExp('3xsin(x)')
|
|
37
37
|
|
|
@@ -52,7 +52,7 @@ describe('Numerical expression', () => { // the tests container
|
|
|
52
52
|
expect(expr2.evaluate({x: 2})).to.be.equal(1)
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
it('should calculate sqrt from exp', function(){
|
|
55
|
+
it('should calculate sqrt from exp', function () {
|
|
56
56
|
let k = new NumExp('nthrt(x,3)')
|
|
57
57
|
expect(k.evaluate({x: -8})).to.be.equal(-2)
|
|
58
58
|
expect(k.evaluate({x: 27})).to.be.equal(3)
|
|
@@ -73,4 +73,17 @@ describe('Numerical expression', () => { // the tests container
|
|
|
73
73
|
let k = new NumExp('2pi')
|
|
74
74
|
expect(+k.evaluate().toFixed(6)).to.be.equal(6.283185)
|
|
75
75
|
});
|
|
76
|
+
|
|
77
|
+
it('should parse with ln or log', function () {
|
|
78
|
+
let k = new NumExp('ln(3)')
|
|
79
|
+
expect(+k.evaluate().toFixed(6)).to.be.equal(1.098612)
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should parse with sqrt and root', () => {
|
|
83
|
+
const expr1 = new NumExp('sqrt(9)');
|
|
84
|
+
expect(expr1.evaluate()).to.be.equal(3);
|
|
85
|
+
|
|
86
|
+
const expr2 = new NumExp('nthrt(8,3)');
|
|
87
|
+
expect(expr2.evaluate()).to.be.equal(2);
|
|
88
|
+
})
|
|
76
89
|
});
|