pimath 0.0.128 → 0.0.130
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/dist/main.d.ts +39 -0
- package/dist/maths/algebra/equation.d.ts +120 -0
- package/dist/maths/algebra/linearSystem.d.ts +40 -0
- package/dist/maths/algebra/logicalset.d.ts +28 -0
- package/dist/maths/algebra/monom.d.ts +207 -0
- package/dist/maths/algebra/polynom.d.ts +155 -0
- package/dist/maths/algebra/rational.d.ts +44 -0
- package/dist/maths/algebra/study/rationalStudy.d.ts +14 -0
- package/dist/maths/algebra/study.d.ts +140 -0
- package/dist/maths/coefficients/fraction.d.ts +90 -0
- package/dist/maths/coefficients/nthRoot.d.ts +23 -0
- package/dist/maths/geometry/circle.d.ts +46 -0
- package/dist/maths/geometry/line.d.ts +102 -0
- package/dist/maths/geometry/point.d.ts +36 -0
- package/dist/maths/geometry/triangle.d.ts +92 -0
- package/dist/maths/geometry/vector.d.ts +38 -0
- package/dist/maths/numeric.d.ts +28 -0
- package/dist/maths/numexp.d.ts +19 -0
- package/dist/maths/randomization/random.d.ts +26 -0
- package/dist/maths/randomization/randomCore.d.ts +7 -0
- package/dist/maths/randomization/rndFraction.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryCircle.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryLine.d.ts +13 -0
- package/dist/maths/randomization/rndGeometryPoint.d.ts +13 -0
- package/dist/maths/randomization/rndHelpers.d.ts +23 -0
- package/dist/maths/randomization/rndMonom.d.ts +13 -0
- package/dist/maths/randomization/rndPolynom.d.ts +14 -0
- package/dist/maths/randomization/rndTypes.d.ts +40 -0
- package/dist/maths/shutingyard.d.ts +59 -0
- package/dist/pimath.js +85 -85
- package/lib/main.ts +42 -0
- package/{src → lib}/maths/algebra/equation.ts +52 -58
- package/{src → lib}/maths/algebra/linearSystem.ts +5 -6
- package/lib/maths/algebra/logicalset.ts +183 -0
- package/{src → lib}/maths/algebra/monom.ts +7 -8
- package/{src → lib}/maths/algebra/polynom.ts +2 -2
- package/{src → lib}/maths/algebra/study.ts +9 -9
- package/{src → lib}/maths/coefficients/fraction.ts +4 -4
- package/{src → lib}/maths/geometry/circle.ts +6 -9
- package/{src → lib}/maths/geometry/line.ts +1 -1
- package/{src → lib}/maths/geometry/vector.ts +35 -34
- package/{src → lib}/maths/numexp.ts +91 -77
- package/{src → lib}/maths/randomization/rndHelpers.ts +1 -1
- package/{src → lib}/maths/randomization/rndMonom.ts +13 -13
- package/{src → lib}/maths/randomization/rndPolynom.ts +24 -24
- package/package.json +11 -12
- package/.eslintrc.js +0 -24
- package/.idea/$CACHE_FILE$ +0 -6
- package/.idea/PI.iml +0 -14
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/php.xml +0 -19
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +0 -192
- 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 +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +0 -2404
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +0 -1362
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +0 -4
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +0 -90
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +0 -4
- package/.idea/vcs.xml +0 -6
- package/dist/demo/exercises.html +0 -283
- package/dist/demo/matrices.html +0 -39
- package/dist/demo/playground.html +0 -20
- package/dist/demo.css +0 -3
- package/dist/pimath.umd.cjs +0 -15
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -78
- package/docs/assets/main.js +0 -59
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1383
- package/docs/classes/Logicalset.Logicalset.html +0 -217
- package/docs/classes/Polynom.Rational.html +0 -397
- package/docs/classes/Vector-1.Vector.html +0 -490
- package/docs/classes/Vector.Point.html +0 -337
- package/docs/classes/algebra_equation.Equation.html +0 -790
- package/docs/classes/algebra_linearSystem.LinearSystem.html +0 -404
- package/docs/classes/algebra_monom.Monom.html +0 -962
- package/docs/classes/algebra_polynom.Polynom.html +0 -1275
- package/docs/classes/coefficients_fraction.Fraction.html +0 -934
- package/docs/classes/geometry_circle.Circle.html +0 -472
- package/docs/classes/geometry_line.Line.html +0 -774
- package/docs/classes/geometry_triangle.Triangle.html +0 -429
- package/docs/classes/numeric.Numeric.html +0 -265
- package/docs/classes/shutingyard.Shutingyard.html +0 -250
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +0 -83
- package/docs/enums/geometry_line.LinePropriety.html +0 -97
- package/docs/enums/shutingyard.ShutingyardMode.html +0 -97
- package/docs/enums/shutingyard.ShutingyardType.html +0 -111
- package/docs/index.html +0 -63
- package/docs/interfaces/algebra_equation.ISolution.html +0 -105
- package/docs/interfaces/algebra_polynom.IEuclidian.html +0 -87
- package/docs/interfaces/geometry_triangle.remarquableLines.html +0 -163
- package/docs/modules/Logicalset.html +0 -65
- package/docs/modules/Polynom.html +0 -65
- package/docs/modules/Vector-1.html +0 -65
- package/docs/modules/Vector.html +0 -65
- package/docs/modules/algebra_equation.html +0 -69
- package/docs/modules/algebra_linearSystem.html +0 -61
- package/docs/modules/algebra_monom.html +0 -65
- package/docs/modules/algebra_polynom.html +0 -69
- package/docs/modules/coefficients_fraction.html +0 -65
- package/docs/modules/geometry_circle.html +0 -61
- package/docs/modules/geometry_line.html +0 -65
- package/docs/modules/geometry_triangle.html +0 -65
- package/docs/modules/numeric.html +0 -61
- package/docs/modules/shutingyard.html +0 -75
- package/docs/types/algebra_monom.literalType.html +0 -61
- package/docs/types/algebra_polynom.PolynomParsingType.html +0 -56
- package/docs/types/coefficients_fraction.FractionParsingType.html +0 -56
- package/docs/types/shutingyard.Token.html +0 -63
- package/docs/types/shutingyard.tokenType.html +0 -68
- package/docs/variables/shutingyard.tokenConstant.html +0 -61
- package/index.html +0 -15
- package/public/demo/exercises.html +0 -283
- package/public/demo/matrices.html +0 -39
- package/public/demo/playground.html +0 -20
- package/public/demo.css +0 -3
- package/src/demo/exercises.ts +0 -0
- package/src/demo/matrices.ts +0 -61
- package/src/demo/playground.ts +0 -153
- package/src/main.ts +0 -42
- package/src/maths/algebra/logicalset.ts +0 -183
- package/tests/algebra/equation.test.ts +0 -64
- package/tests/algebra/linear.test.ts +0 -58
- package/tests/algebra/monom.test.ts +0 -78
- package/tests/algebra/polynom.test.ts +0 -343
- package/tests/algebra/rationnal.test.ts +0 -64
- package/tests/algebra/study.test.ts +0 -48
- package/tests/coefficients/fraction.test.ts +0 -131
- package/tests/custom.test.ts +0 -33
- package/tests/geometry/circle.test.ts +0 -404
- package/tests/geometry/line.test.ts +0 -36
- package/tests/numeric.test.ts +0 -43
- package/tests/numexp.test.ts +0 -89
- package/tests/shutingyard.test.ts +0 -58
- package/tsconfig.json +0 -52
- package/tsconfig.testing.json +0 -28
- package/typedoc.katex.js +0 -11
- package/vite.config.js +0 -23
- package/webpack-production-min.config.js +0 -26
- package/webpack-production.config.js +0 -26
- package/webpack.config.js +0 -26
- /package/{src → lib}/maths/algebra/rational.ts +0 -0
- /package/{src → lib}/maths/algebra/study/rationalStudy.ts +0 -0
- /package/{src → lib}/maths/coefficients/nthRoot.ts +0 -0
- /package/{src → lib}/maths/geometry/point.ts +0 -0
- /package/{src → lib}/maths/geometry/triangle.ts +0 -0
- /package/{src → lib}/maths/numeric.ts +0 -0
- /package/{src → lib}/maths/randomization/random.ts +0 -0
- /package/{src → lib}/maths/randomization/randomCore.ts +0 -0
- /package/{src → lib}/maths/randomization/rndFraction.ts +0 -0
- /package/{src → lib}/maths/randomization/rndGeometryCircle.ts +0 -0
- /package/{src → lib}/maths/randomization/rndGeometryLine.ts +0 -0
- /package/{src → lib}/maths/randomization/rndGeometryPoint.ts +0 -0
- /package/{src → lib}/maths/randomization/rndTypes.ts +0 -0
- /package/{src → lib}/maths/shutingyard.ts +0 -0
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
import {describe} from "mocha";
|
|
2
|
-
import {expect} from "chai";
|
|
3
|
-
import {Circle} from "../../src/maths/geometry/circle";
|
|
4
|
-
import {Line} from "../../src/maths/geometry/line";
|
|
5
|
-
import {Point} from "../../src/maths/geometry/point";
|
|
6
|
-
import {Fraction} from "../../src/maths/coefficients/fraction";
|
|
7
|
-
import {Random} from "../../src/maths/randomization/random";
|
|
8
|
-
import {Vector} from "../../src/maths/geometry/vector";
|
|
9
|
-
|
|
10
|
-
describe('Circle', function () {
|
|
11
|
-
it('should calculate the intersection of a circle and a line', function () {
|
|
12
|
-
let C = new Circle(
|
|
13
|
-
new Point(8, 6),
|
|
14
|
-
20,
|
|
15
|
-
true
|
|
16
|
-
),
|
|
17
|
-
LT = new Line('2x+y-32=0'),
|
|
18
|
-
LS = new Line('3x-y-8=0'),
|
|
19
|
-
IPT = C.lineIntersection(LT),
|
|
20
|
-
IPS = C.lineIntersection(LS)
|
|
21
|
-
|
|
22
|
-
expect(IPT).to.be.length(1)
|
|
23
|
-
expect(IPT[0].x.value).to.be.equal(12)
|
|
24
|
-
expect(IPT[0].y.value).to.be.equal(8)
|
|
25
|
-
|
|
26
|
-
expect(IPS).to.be.length(2)
|
|
27
|
-
expect(IPS[0].x.value).to.be.equal(4)
|
|
28
|
-
expect(IPS[0].y.value).to.be.equal(4)
|
|
29
|
-
expect(IPS[1].x.value).to.be.equal(6)
|
|
30
|
-
expect(IPS[1].y.value).to.be.equal(10)
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('should calculate tangents', function () {
|
|
34
|
-
|
|
35
|
-
// Through one point on the circle
|
|
36
|
-
const C = new Circle(
|
|
37
|
-
new Point(-2, 3),
|
|
38
|
-
25,
|
|
39
|
-
true
|
|
40
|
-
), P = new Point(-5, 7);
|
|
41
|
-
|
|
42
|
-
expect(C.tangents(P).map(x => x.tex.canonical)).to.have.all.members(['3x-4y+43=0'])
|
|
43
|
-
|
|
44
|
-
// With a slope
|
|
45
|
-
const D = new Circle('x^2+y^2+10x=2y-6'),
|
|
46
|
-
slope = new Fraction(-2, 1)
|
|
47
|
-
|
|
48
|
-
expect(D.tangents(slope).map(x => x.tex.canonical)).to.have.all.members(['2x+y-1=0', '2x+y+19=0'])
|
|
49
|
-
|
|
50
|
-
const E = new Circle('(x-2)^2+(y-1)^2=5'),
|
|
51
|
-
P2 = new Point(6, -2)
|
|
52
|
-
|
|
53
|
-
expect(E.tangents(P2).map(x => x.tex.canonical)).to.have.all.members(['2x+y-10=0', '2x+11y+10=0'])
|
|
54
|
-
|
|
55
|
-
let P3 = new Point(2, 2)
|
|
56
|
-
expect(E.tangents(P3)).to.be.empty
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('should get a list of point on the circle', function () {
|
|
60
|
-
const C = new Circle('(x-3)^2+(y+4)^2=16'),
|
|
61
|
-
pts = C.getPointsOnCircle()
|
|
62
|
-
|
|
63
|
-
expect(pts.map(x => x.x.display + ',' + x.y.display)).to.have.all.members(['3,0', '3,-8', '7,-4', '-1,-4'])
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('should calculate the circle from center and radius', function () {
|
|
67
|
-
let circle = new Circle("x^2+6x+y^2-8y+12=0")
|
|
68
|
-
|
|
69
|
-
// console.log(circle.tex)
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
it('tangentes pt ext', () => {
|
|
73
|
-
function makeCircle(): { circle: Circle, point: Point, tangents: Line[] } {
|
|
74
|
-
let A = Random.Geometry.point({axis: false}),
|
|
75
|
-
rv = Random.number(1, 3),
|
|
76
|
-
r = rv ** 2 + (rv + 1) ** 2
|
|
77
|
-
let c = new Circle(A, r, true)
|
|
78
|
-
let pts = c.getPointsOnCircle(true)
|
|
79
|
-
|
|
80
|
-
pts = Random.shuffle(pts)
|
|
81
|
-
let pt1: Point, pt2: Point, t1: Line, t2: Line, I: Point, n: Vector
|
|
82
|
-
|
|
83
|
-
pt1 = pts.shift()
|
|
84
|
-
for (let pt of pts) {
|
|
85
|
-
// Pas vertical / horizontal
|
|
86
|
-
n = new Vector(A, pt)
|
|
87
|
-
|
|
88
|
-
if (!n.x.isZero() && !n.y.isZero() && // pas vertical / horizontal
|
|
89
|
-
!pt1.x.isEqual(pt.x) && !pt1.y.isEqual(pt.y) && // pas le même point
|
|
90
|
-
!A.isEqual(new Point().middleOf(pt1, pt)) // pas l'un en face de l'autre
|
|
91
|
-
) {
|
|
92
|
-
pt2 = pt.clone()
|
|
93
|
-
|
|
94
|
-
t1 = c.tangents(pt1)[0]
|
|
95
|
-
t2 = c.tangents(pt2)[0]
|
|
96
|
-
const intersection = t1.intersection(t2)
|
|
97
|
-
|
|
98
|
-
if (intersection.hasIntersection && intersection.point.x.isRelative()) {
|
|
99
|
-
I = intersection.point
|
|
100
|
-
break
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
circle: c,
|
|
108
|
-
tangents: [t1, t2],
|
|
109
|
-
point: I
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
for (let i = 0; i < 30; i++) {
|
|
114
|
-
let {circle, tangents, point} = makeCircle()
|
|
115
|
-
console.log(`\\textbf{(exercice ${i + 1})}
|
|
116
|
-
|
|
117
|
-
Calculer l'équation cartésiennes des tangentes au cercle \\( (\\Gamma): ${circle.tex} \\) passant par le point \\(P=${point.tex} \\)
|
|
118
|
-
\\iftoggle{master}{
|
|
119
|
-
(I) \\( ${tangents[0].tex.canonical} \\quad ${tangents[1].tex.canonical} \\)
|
|
120
|
-
}{}
|
|
121
|
-
\\vfill
|
|
122
|
-
${i % 2 === 1 ? '\\newpage' : ''}
|
|
123
|
-
`)
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
const C = new PiMath.Geometry.Circle(circle.value),
|
|
128
|
-
pts = C.getPointsOnCircle()
|
|
129
|
-
|
|
130
|
-
code.value = `C(${C.center.x.value},${C.center.y.value})
|
|
131
|
-
c=circ C,${C.radius.value}`
|
|
132
|
-
|
|
133
|
-
let tangents = []
|
|
134
|
-
pts.forEach((pt, index) => {
|
|
135
|
-
let tg = C.tangents(pt)[0]
|
|
136
|
-
tangents.push(tg)
|
|
137
|
-
code.value += `\nT${index + 1}(${pt.x.value},${pt.y.value})->tex:T_${index + 1}=@`
|
|
138
|
-
code.value += `\nt${index + 1}=line ${tg.tex.canonical}`
|
|
139
|
-
|
|
140
|
-
tangentPerPoints.value.push(`T_${index+1}(${pt.x.tex};${pt.y.tex})\\implies ${tg.tex.canonical}`)
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
for (let i = 0; i < tangents.length; i++) {
|
|
144
|
-
for (let j = i + 1; j < tangents.length; j++) {
|
|
145
|
-
let intersection = tangents[i].intersection(tangents[j])
|
|
146
|
-
|
|
147
|
-
if (intersection.hasIntersection) {
|
|
148
|
-
if (!intersection.point.isInListOfPoints(pts)) {
|
|
149
|
-
intersection.point.name=`I_{${i + 1}-${j + 1}}`
|
|
150
|
-
intersectionPoints.value.push({
|
|
151
|
-
point: `I_{${i+1}-${j+1}}${intersection.point.tex}`,
|
|
152
|
-
tangent1: tangents[i].tex.canonical,
|
|
153
|
-
tangent2: tangents[j].tex.canonical
|
|
154
|
-
})
|
|
155
|
-
code.value += `\nI_${i + 1}_${j + 1}(${intersection.point.x.value},${intersection.point.y.value})->tex:I_{${i+1}-${i+2}}=@`
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
*/
|
|
161
|
-
})
|
|
162
|
-
it('tangentes temp tests', () => {
|
|
163
|
-
function makeCircle(): { circle: Circle, point: Point, tangent: Line, symetric: Line } {
|
|
164
|
-
let A = Random.Geometry.point({axis: false}),
|
|
165
|
-
rv = Random.number(1, 3),
|
|
166
|
-
r = rv ** 2 + (rv + 1) ** 2
|
|
167
|
-
let c = new Circle(A, r, true)
|
|
168
|
-
let pts = c.getPointsOnCircle(true)
|
|
169
|
-
|
|
170
|
-
pts = Random.shuffle(pts)
|
|
171
|
-
let pt: Point, n: Vector
|
|
172
|
-
for (let p of pts) {
|
|
173
|
-
n = new Vector(A, p)
|
|
174
|
-
if (!n.x.isZero() && !n.y.isZero()) {
|
|
175
|
-
pt = p
|
|
176
|
-
break
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const p2 = new Point(A.x.clone(), A.y.clone()).translate({x: n.x.opposed(), y: n.y.opposed()})
|
|
181
|
-
const t = new Line(n, pt)
|
|
182
|
-
const s = new Line(n, p2)
|
|
183
|
-
return {
|
|
184
|
-
circle: c,
|
|
185
|
-
point: pt,
|
|
186
|
-
tangent: t,
|
|
187
|
-
symetric: s
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
for (let i = 0; i < 30; i++) {
|
|
192
|
-
|
|
193
|
-
const data1 = makeCircle()
|
|
194
|
-
const item1 = `Calculer l'équation de la tangente au cercle d'équation \\( (\\Gamma_1): ${data1.circle.tex} \\) un cercle passant par le point \\( T=${data1.point.tex} \\).`
|
|
195
|
-
|
|
196
|
-
const data2 = makeCircle()
|
|
197
|
-
const item2 = `Calculer l'équation des tangentes au cercle d'équation \\( (\\Gamma_2): ${data2.circle.cartesian.tex} \\) de pente \\( \\displaystyle ${data2.tangent.slope.tex} \\).`
|
|
198
|
-
|
|
199
|
-
console.log(`\\textbf{(exercice ${i + 1})}
|
|
200
|
-
|
|
201
|
-
\\begin{enumerate}[(I),itemsep=10em]
|
|
202
|
-
\\item ${item1}
|
|
203
|
-
\\item ${item2}
|
|
204
|
-
\\end{enumerate}
|
|
205
|
-
\\iftoggle{master}{
|
|
206
|
-
(I) \\( ${data1.tangent.tex.canonical} \\)
|
|
207
|
-
|
|
208
|
-
(II) \\( (\\Gamma_2): ${data2.circle.tex} \\) \\\\ \\( (t_1): ${data2.tangent.tex.canonical} \\) et \\( (t_2): ${data2.symetric.tex.canonical} \\)
|
|
209
|
-
|
|
210
|
-
}{}
|
|
211
|
-
\\vfill
|
|
212
|
-
${i % 2 === 1 ? '\\newpage' : ''}
|
|
213
|
-
`)
|
|
214
|
-
|
|
215
|
-
}
|
|
216
|
-
})
|
|
217
|
-
// it('intersection temp tests', () => {
|
|
218
|
-
// for (let i = 0; i < 30; i++) {
|
|
219
|
-
// let A = Random.Geometry.point({axis: false}),
|
|
220
|
-
// rv = Random.number(1, 3),
|
|
221
|
-
// r = rv ** 2 + (rv + 1) ** 2
|
|
222
|
-
//
|
|
223
|
-
// let c = new Circle(A, r, true)
|
|
224
|
-
// let pts = c.getPointsOnCircle(true)
|
|
225
|
-
// // console.log(r, pts.length)
|
|
226
|
-
//
|
|
227
|
-
// // console.log(c.tex)
|
|
228
|
-
// // console.log(pts.map(pt => pt.display))
|
|
229
|
-
// pts = Random.shuffle(pts)
|
|
230
|
-
// let ptt = pts.shift(),
|
|
231
|
-
// pt1 = pts.shift(),
|
|
232
|
-
// pt2
|
|
233
|
-
//
|
|
234
|
-
// for (let pt of pts) {
|
|
235
|
-
// if (!pt1.x.isEqual(pt.x) && !pt1.y.isEqual(pt.y) && !A.isEqual(new Point().middleOf(pt1, pt))) {
|
|
236
|
-
// pt2 = pt.clone()
|
|
237
|
-
// break
|
|
238
|
-
// }
|
|
239
|
-
// }
|
|
240
|
-
//
|
|
241
|
-
// // console.log('Pt de tangence')
|
|
242
|
-
// // console.log(ptt.display)
|
|
243
|
-
// let t = c.tangents(ptt)[0]
|
|
244
|
-
// // console.log(t.tex.canonical)
|
|
245
|
-
//
|
|
246
|
-
// // console.log('intersection en deux points')
|
|
247
|
-
// // console.log(pt1.display, pt2.display)
|
|
248
|
-
// let d = new Line(pt1, pt2)
|
|
249
|
-
// // console.log(d.tex.canonical)
|
|
250
|
-
//
|
|
251
|
-
// let P = Random.Geometry.point()
|
|
252
|
-
// while (P.x.isEqual(c.center.x) || P.y.isEqual(c.center.y)) {
|
|
253
|
-
// P = Random.Geometry.point()
|
|
254
|
-
// }
|
|
255
|
-
// // Le point P n'est pas sur le centre.
|
|
256
|
-
// let v = new Vector(c.center, P)
|
|
257
|
-
// while (P.distanceTo(A).value <= Math.sqrt(r)) {
|
|
258
|
-
// P.x.add(v.x)
|
|
259
|
-
// P.y.add(v.y)
|
|
260
|
-
// }
|
|
261
|
-
// let p = new Line(P, v, LinePropriety.Perpendicular)
|
|
262
|
-
// // console.log(P.display)
|
|
263
|
-
// // console.log(p.display.canonical)
|
|
264
|
-
//
|
|
265
|
-
// let lignes = Random.shuffle([t, d, p])
|
|
266
|
-
//
|
|
267
|
-
// // console.log(`A${A.display}
|
|
268
|
-
// // c=circ A,${Math.sqrt(r)}
|
|
269
|
-
// // T${ptt.display}
|
|
270
|
-
// // P${pt1.display}
|
|
271
|
-
// // Q${pt2.display}
|
|
272
|
-
// // t=line ${t.display.canonical}
|
|
273
|
-
// // d=line ${d.display.canonical}
|
|
274
|
-
// // p=line ${p.display.canonical}`)
|
|
275
|
-
// console.log(`(exercice ${i + 1}): Soit \\(\\Gamma\\) un cercle et \\(d_1\\), \\(d_2\\) et \\(d_3\\) trois droites.
|
|
276
|
-
// \\mathleft
|
|
277
|
-
// \\[(\\Gamma): ${c.tex}\\]
|
|
278
|
-
// \\[(d_1): ${lignes[0].tex.canonical} \\qquad (d_2): ${lignes[1].tex.canonical} \\qquad (d_3): ${lignes[2].tex.canonical}\\]
|
|
279
|
-
//
|
|
280
|
-
// \\begin{enumerate}[label=\\Alph*]
|
|
281
|
-
// \\item déterminer les positions relatives de \\(d_1\\), \\(d_2\\) et \\(d_3\\) par rapport à \\(\\Gamma\\)
|
|
282
|
-
// \\item calculer les coordonnées du ou des points d'intersection entre le cercle et une des droites qui le coupe (au choix).
|
|
283
|
-
// \\end{enumerate}
|
|
284
|
-
// \\iftoggle{master}{\\(${t.tex.canonical}\\implies ${ptt.tex}\\) \\\\ \\(${d.tex.canonical}\\implies ${pt1.tex},\\ ${pt2.tex}\\) \\\\}{}
|
|
285
|
-
// \\vfill
|
|
286
|
-
// ${i % 2 === 1 ? '\\newpage' : ''}
|
|
287
|
-
// `)
|
|
288
|
-
//
|
|
289
|
-
// }
|
|
290
|
-
//
|
|
291
|
-
// })
|
|
292
|
-
// it('temp tests', () => {
|
|
293
|
-
// for (let i = 0; i < 30; i++) {
|
|
294
|
-
// let A = Random.Geometry.point({axis: false}),
|
|
295
|
-
// B = Random.Geometry.point({axis: false})
|
|
296
|
-
//
|
|
297
|
-
// if (Random.bool()) {
|
|
298
|
-
// B.x = new Fraction().zero()
|
|
299
|
-
// } else {
|
|
300
|
-
// B.y = new Fraction().zero()
|
|
301
|
-
// }
|
|
302
|
-
//
|
|
303
|
-
// const c1 = new Circle(A, Random.number(1, 10)),
|
|
304
|
-
// c2 = new Circle(B, Random.number(1, 10))
|
|
305
|
-
//
|
|
306
|
-
// 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.
|
|
307
|
-
// \\begin{enumerate}[label=\\Alph*]
|
|
308
|
-
// \\item \\( (\\Gamma_1): ${c1.developed}\\) \\iftoggle{master}{\\(${c1.tex}\\)}{}
|
|
309
|
-
// \\item \\( (\\Gamma_2): ${c2.developed}\\) \\iftoggle{master}{\\(${c2.tex}\\)}{}
|
|
310
|
-
// \\end{enumerate}
|
|
311
|
-
// \\vfill
|
|
312
|
-
// ${i % 2 === 1 ? '\\newpage' : ''}
|
|
313
|
-
// `)
|
|
314
|
-
// }
|
|
315
|
-
// })
|
|
316
|
-
//
|
|
317
|
-
// it('temp tests 2', () => {
|
|
318
|
-
// const q = `(I): Soit \\(\\Gamma_1\\) et \\(\\Gamma_2\\) deux cercles. Déterminer leur position relative à l'aide des informations ci-dessous.
|
|
319
|
-
//
|
|
320
|
-
// \\[(\\Gamma_1): @G1 \\qquad (\\Gamma_2): @G2 \\]
|
|
321
|
-
// \\[\\trou{@R1} \\]
|
|
322
|
-
//
|
|
323
|
-
// \\vspace{3cm}
|
|
324
|
-
// (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.\\\\
|
|
325
|
-
// Préciser la position relative entre \\(\\Gamma_3\\) et \\(\\Gamma_4\\)
|
|
326
|
-
// \\[ \\trou{@R2a} \\]
|
|
327
|
-
// \\[ \\trou{@R2b} \\]
|
|
328
|
-
// `
|
|
329
|
-
//
|
|
330
|
-
// for (let i = 0; i < 30; i++) {
|
|
331
|
-
// let A = Random.Geometry.point({axis: false}),
|
|
332
|
-
// triplet = Random.item(Numeric.pythagoricianTripletsWithTarget(
|
|
333
|
-
// Random.item([5, 13, 17, 25, 29, 37, 41])
|
|
334
|
-
// ).filter(tr => {
|
|
335
|
-
// // remove all items with zero values.
|
|
336
|
-
// return tr.every(x => x !== 0)
|
|
337
|
-
// })),
|
|
338
|
-
// B = new Point(
|
|
339
|
-
// A.x.value + triplet[0],
|
|
340
|
-
// A.y.value + triplet[1]
|
|
341
|
-
// ),
|
|
342
|
-
// delta = Random.number(2, triplet[2] - 1),
|
|
343
|
-
// positionRelative = ['extérieure', 'intérieure', 'sécante', 'disjointe'][i % 4],
|
|
344
|
-
// // positionRelative = Random.item(['extérieure', 'intérieure', 'sécante', 'disjointe']),
|
|
345
|
-
// c1: Circle, c2: Circle
|
|
346
|
-
//
|
|
347
|
-
// if (positionRelative === 'extérieure') {
|
|
348
|
-
// c1 = new Circle(A, triplet[2] - delta)
|
|
349
|
-
// c2 = new Circle(B, delta)
|
|
350
|
-
// } else if (positionRelative === 'intérieure') {
|
|
351
|
-
// c1 = new Circle(A, triplet[2] + delta)
|
|
352
|
-
// c2 = new Circle(B, delta)
|
|
353
|
-
// } else if (positionRelative === 'sécante') {
|
|
354
|
-
// c1 = new Circle(A, triplet[2] + delta - Random.number(1, delta - 1))
|
|
355
|
-
// c2 = new Circle(B, delta)
|
|
356
|
-
// } else if (positionRelative === 'disjointe') {
|
|
357
|
-
// c1 = new Circle(A, triplet[2] + delta + 1)
|
|
358
|
-
// c2 = new Circle(B, delta)
|
|
359
|
-
// }
|
|
360
|
-
//
|
|
361
|
-
// 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}} `
|
|
362
|
-
//
|
|
363
|
-
//
|
|
364
|
-
// let C = Random.Geometry.point({axis: false}),
|
|
365
|
-
// r1 = Random.number(2, 10),
|
|
366
|
-
// c3 = new Circle(C, r1),
|
|
367
|
-
// // Get a random number from 2 to 10 that is not equal to r1
|
|
368
|
-
// r2 = Random.number(2, 10, [r1]),
|
|
369
|
-
// axis = Random.item(['abscisse', 'ordonnée']),
|
|
370
|
-
// centers: Point[] = []
|
|
371
|
-
//
|
|
372
|
-
// const c3x = c3.center.x.value,
|
|
373
|
-
// c3y = c3.center.y.value
|
|
374
|
-
// if (axis === 'abscisse') {
|
|
375
|
-
//
|
|
376
|
-
// centers = [
|
|
377
|
-
// new Point(c3x, c3y - (r1 + r2)),
|
|
378
|
-
// new Point(c3x, c3y - (r2 - r1)),
|
|
379
|
-
// new Point(c3x, c3y - (r1 - r2)),
|
|
380
|
-
// new Point(c3x, c3y + (r1 + r2))
|
|
381
|
-
// ]
|
|
382
|
-
// } else {
|
|
383
|
-
// centers = [
|
|
384
|
-
// new Point(c3x - (r1 + r2), c3y),
|
|
385
|
-
// new Point(c3x - (r2 - r1), c3y),
|
|
386
|
-
// new Point(c3x - (r1 - r2), c3y),
|
|
387
|
-
// new Point(c3x + (r1 + r2), c3y)
|
|
388
|
-
// ]
|
|
389
|
-
// }
|
|
390
|
-
//
|
|
391
|
-
// console.log(`(exercice ${i + 1}): ` + q
|
|
392
|
-
// .replaceAll('@G1', c1.tex)
|
|
393
|
-
// .replaceAll('@R1', R1)
|
|
394
|
-
// .replaceAll('@G2', c2.tex)
|
|
395
|
-
// .replaceAll('@G3', c3.developed)
|
|
396
|
-
// .replaceAll('@RAYON', r2.toString())
|
|
397
|
-
// .replaceAll('@AXE', axis)
|
|
398
|
-
// .replaceAll('@R2a', centers.slice(0, 2).map(x => new Circle(x, r2).tex).join(' \\qquad '))
|
|
399
|
-
// .replaceAll('@R2b', centers.slice(2, 4).map(x => new Circle(x, r2).tex).join(' \\qquad '))
|
|
400
|
-
// + '\\vfill' + (i % 2 === 1 ? '\\newpage' : '')
|
|
401
|
-
// )
|
|
402
|
-
// }
|
|
403
|
-
// })
|
|
404
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {describe} from "mocha";
|
|
2
|
-
import {Line} from "../../src/maths/geometry/line";
|
|
3
|
-
import {Point} from "../../src/maths/geometry/point";
|
|
4
|
-
import {expect} from "chai";
|
|
5
|
-
|
|
6
|
-
describe('Geometry Line', function () {
|
|
7
|
-
it('should evaluate coordinates', function () {
|
|
8
|
-
let L = new Line('3x-4y+5=0')
|
|
9
|
-
|
|
10
|
-
let y = L.getValueAtX(0)
|
|
11
|
-
expect(y.display).to.be.equal('5/4')
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('should output nice Tex', function () {
|
|
15
|
-
let L = new Line('9x-8y-96=0'),
|
|
16
|
-
tex = L.tex
|
|
17
|
-
|
|
18
|
-
expect(tex.canonical).to.be.equal('9x-8y-96=0')
|
|
19
|
-
expect(tex.equation).to.be.equal('9x-8y=96')
|
|
20
|
-
expect(tex.mxh).to.be.equal('y=\\frac{ 9 }{ 8 }x-12')
|
|
21
|
-
expect(tex.parametric).to.be.equal('\\begin{pmatrix} x \\\\ y \\end{pmatrix} = \\begin{pmatrix} 0 \\\\ -96 \\end{pmatrix} + k\\cdot \\begin{pmatrix} -8 \\\\ -9 \\end{pmatrix}')
|
|
22
|
-
// console.log(tex.system)
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('should parse line from canonical coefficient', function () {
|
|
26
|
-
// parse by canonical coefficients ax+by+c=0
|
|
27
|
-
// a=3, b=2, c=1
|
|
28
|
-
let L = new Line(3, 2, 1)
|
|
29
|
-
|
|
30
|
-
let P1 = new Point(-2, 3),
|
|
31
|
-
P2 = new Point(-3, 4)
|
|
32
|
-
expect(L.isOnLine(P1)).to.be.false
|
|
33
|
-
expect(L.isOnLine(P2)).to.be.true
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
});
|
package/tests/numeric.test.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import {Numeric} from "../src/maths/numeric";
|
|
2
|
-
import {expect} from "chai";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
describe('Numeric', () => { // the tests container
|
|
6
|
-
it('Correct number', () => {
|
|
7
|
-
const a = 0.1 + 0.2
|
|
8
|
-
expect(Numeric.numberCorrection(a)).to.be.equal(0.3)
|
|
9
|
-
const b = Math.pow(10, -5)
|
|
10
|
-
|
|
11
|
-
expect(Numeric.numberCorrection(b, 1, 12)).to.be.equal(0.00001)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
it('should simplify numbers by the gcd', () => {
|
|
16
|
-
let a = 12, b = 15, c = 33, d = 303;
|
|
17
|
-
|
|
18
|
-
[a, b, c, d] = Numeric.divideNumbersByGCD(a, b, c, d)
|
|
19
|
-
|
|
20
|
-
expect([a, b, c, d]).to.have.all.members([4, 5, 11, 101])
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('should decompose a number in two factors', function () {
|
|
24
|
-
expect(Numeric.decompose(25).map(x => x.join(','))).to.have.all.members(['1,25', '5,5'])
|
|
25
|
-
expect(Numeric.decompose(6).map(x => x.join(','))).to.have.all.members(['1,6', '2,3'])
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('algo perso', () => {
|
|
29
|
-
for (let n = 1000; n < 10000; n++) {
|
|
30
|
-
const a = Math.trunc(n / 1000)
|
|
31
|
-
const b = Math.trunc((n - 1000 * a) / 100)
|
|
32
|
-
const c = Math.trunc((n - 1000 * a - 100 * b) / 10)
|
|
33
|
-
const d = Math.trunc(n - 1000 * a - 100 * b - 10 * c)
|
|
34
|
-
|
|
35
|
-
const p = a + b + c + d
|
|
36
|
-
const p2 = a ** 2 + b ** 2 + c ** 2 + d ** 2
|
|
37
|
-
|
|
38
|
-
if (n === p * p2 ** 2) {
|
|
39
|
-
console.log(n)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
});
|
package/tests/numexp.test.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {expect} from 'chai';
|
|
2
|
-
import {NumExp} from "../src/maths/numexp";
|
|
3
|
-
|
|
4
|
-
describe('Numerical expression', () => { // the tests container
|
|
5
|
-
it('RPN for numerical expression', () => {
|
|
6
|
-
const RPN = new NumExp('3*x+5').rpn
|
|
7
|
-
expect(RPN.map(x => x.token)).to.have.all.members(['3', 'x', '*', '5', '+'])
|
|
8
|
-
|
|
9
|
-
const RPN2 = new NumExp('-3*x^2-5').rpn
|
|
10
|
-
expect(RPN2.map(x => x.token)).to.have.all.members(['3', 'x', '2', '^', '*', '-', '5', '-'])
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('Evaluate for numerical expression', () => {
|
|
14
|
-
const expr = new NumExp('3*x+5')
|
|
15
|
-
expect(expr.evaluate({x: 5})).to.be.equal(20)
|
|
16
|
-
|
|
17
|
-
const expr2 = new NumExp('-3*x^2-5')
|
|
18
|
-
expect(expr2.evaluate({x: -2})).to.be.equal(-17)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
it('Evaluation simple mathematical functions', () => {
|
|
22
|
-
const expr = new NumExp('sqrt(x)')
|
|
23
|
-
expect(expr.evaluate({x: 9})).to.be.equal(3)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('should detect invalid rpn parsing', function () {
|
|
27
|
-
const exprValid = new NumExp('3*sin(x)'),
|
|
28
|
-
exprInvalid = new NumExp('3*sin')
|
|
29
|
-
|
|
30
|
-
expect(exprValid.isValid).to.be.true
|
|
31
|
-
expect(exprInvalid.isValid).to.be.false
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('souldd detect invalid expression withouth crahsing', function () {
|
|
35
|
-
const exprPourrie = new NumExp('3xsi'),
|
|
36
|
-
exprOk = new NumExp('3xsin(x)')
|
|
37
|
-
|
|
38
|
-
expect(exprPourrie.isValid).to.be.false
|
|
39
|
-
expect(exprOk.isValid).to.be.true
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
it('should parse without mult sign', function () {
|
|
43
|
-
|
|
44
|
-
let a = 1 / 5
|
|
45
|
-
|
|
46
|
-
const expr = new NumExp('3x-5', true)
|
|
47
|
-
expect(expr.isValid).to.be.true
|
|
48
|
-
expect(expr.evaluate({x: 2})).to.be.equal(1)
|
|
49
|
-
|
|
50
|
-
const expr2 = new NumExp('3*x-5', true)
|
|
51
|
-
expect(expr2.isValid).to.be.true
|
|
52
|
-
expect(expr2.evaluate({x: 2})).to.be.equal(1)
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should calculate sqrt from exp', function () {
|
|
56
|
-
let k = new NumExp('nthrt(x,3)')
|
|
57
|
-
expect(k.evaluate({x: -8})).to.be.equal(-2)
|
|
58
|
-
expect(k.evaluate({x: 27})).to.be.equal(3)
|
|
59
|
-
|
|
60
|
-
let p = new NumExp('nthrt(x,4)')
|
|
61
|
-
expect(p.evaluate({x: 16})).to.be.equal(2)
|
|
62
|
-
expect(p.evaluate({x: -16})).to.be.NaN
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it('should work with constant', function () {
|
|
66
|
-
|
|
67
|
-
let k = new NumExp('2pi*x')
|
|
68
|
-
expect(+k.evaluate({x: 1}).toFixed(6)).to.be.equal(6.283185)
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('should work with constant but without variables', function () {
|
|
72
|
-
|
|
73
|
-
let k = new NumExp('2pi')
|
|
74
|
-
expect(+k.evaluate().toFixed(6)).to.be.equal(6.283185)
|
|
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
|
-
})
|
|
89
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import {expect} from 'chai';
|
|
2
|
-
import {Shutingyard, ShutingyardMode} from "../src/maths/shutingyard";
|
|
3
|
-
|
|
4
|
-
describe('Shuting yard', () => { // the tests container
|
|
5
|
-
it('RPN for polynom', () => {
|
|
6
|
-
const SY0: Shutingyard = new Shutingyard().parse('3+x+5');
|
|
7
|
-
const SY1: Shutingyard = new Shutingyard().parse('3x+5');
|
|
8
|
-
const SY2: Shutingyard = new Shutingyard().parse('3.2x+5');
|
|
9
|
-
const SY3: Shutingyard = new Shutingyard().parse('3/2x+5');
|
|
10
|
-
const SY3b: Shutingyard = new Shutingyard().parse('3/2(x+5)');
|
|
11
|
-
const SY4: Shutingyard = new Shutingyard().parse('3/2x^2-5xy-12');
|
|
12
|
-
const SY5: Shutingyard = new Shutingyard().parse('3/2x^(-3)-5xy-12');
|
|
13
|
-
const SY6: Shutingyard = new Shutingyard().parse('x^3y^2z');
|
|
14
|
-
|
|
15
|
-
expect(SY0.rpn.map(x=>x.token)).to.have.all.members(['3', 'x', '+', '5', '+'])
|
|
16
|
-
expect(SY1.rpn.map(x=>x.token)).to.have.all.members(['3', 'x', '*', '5', '+'])
|
|
17
|
-
expect(SY2.rpn.map(x=>x.token)).to.have.all.members(['3.2', 'x', '*', '5', '+'])
|
|
18
|
-
expect(SY3.rpn.map(x=>x.token)).to.have.all.members(['3', '2', '/', 'x', '*', '5', '+'])
|
|
19
|
-
expect(SY3b.rpn.map(x=>x.token)).to.have.all.members(['3', '2', '/', 'x', '5', '+', '*'])
|
|
20
|
-
expect(SY4.rpn.map(x=>x.token)).to.have.all.members(['3', '2', '/', 'x', '2', '^', '*', '5', 'x', '*', 'y', '*', '-', '12', '-'])
|
|
21
|
-
expect(SY5.rpn.map(x=>x.token)).to.have.all.members(['3', '2', '/', 'x', '0', '3', '-', '^', '*', '5', 'x', '*', 'y', '*', '-', '12', '-'])
|
|
22
|
-
expect(SY6.rpn.map(x=>x.token)).to.have.all.members(['x', '3', '^', 'y', '2', '^', '*', 'z', '*'])
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
it('RPN for multi variable polynom', ()=> {
|
|
26
|
-
const SY: Shutingyard = new Shutingyard().parse('ax+by+c')
|
|
27
|
-
expect(SY.rpn.map(x=>x.token)).to.have.all.members(["a","x","*","b","y","*","+","c","+"])
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it('Custom RPN', () => {
|
|
31
|
-
const SY1: Shutingyard = new Shutingyard(ShutingyardMode.SET).parse('(A|B)&C');
|
|
32
|
-
const SY2: Shutingyard = new Shutingyard(ShutingyardMode.SET).parse('(A-B)&!C');
|
|
33
|
-
expect(SY1.rpn.map(x=>x.token)).to.have.all.members(['A', 'B', '|', 'C', '&'])
|
|
34
|
-
expect(SY2.rpn.map(x=>x.token)).to.have.all.members(['A', 'B', '-', 'C', '!', '&'])
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it('should uniformize the expression', ()=>{
|
|
38
|
-
// const SY1: Shutingyard = new Shutingyard(ShutingyardMode.POLYNOM).parse('3xx^2(x+5)')
|
|
39
|
-
// expect(SY1.rpn.map(x=>x.token)).to.have.all.members([
|
|
40
|
-
// '3', 'x', '*', 'x',
|
|
41
|
-
// '2', '^', '*', 'x',
|
|
42
|
-
// '5', '+', '*'
|
|
43
|
-
// ])
|
|
44
|
-
//
|
|
45
|
-
// const SY2: Shutingyard = new Shutingyard(ShutingyardMode.EXPRESSION).parse('3xysqrt(x-b)-ab')
|
|
46
|
-
// expect(SY2.rpn.map(x=>x.token)).to.have.all.members([
|
|
47
|
-
// '3', 'x', '*',
|
|
48
|
-
// 'y', 'x', 'b',
|
|
49
|
-
// '-', 'sqrt', '*',
|
|
50
|
-
// 'a', 'b', '*',
|
|
51
|
-
// '-'
|
|
52
|
-
// ])
|
|
53
|
-
|
|
54
|
-
expect(new Shutingyard(ShutingyardMode.EXPRESSION).normalize('3x(x-5)^(2(x+7))')).to.be.equal("3*x*(x-5)^(2*(x+7))")
|
|
55
|
-
expect(new Shutingyard(ShutingyardMode.EXPRESSION).normalize('sin(cos(3pi-5))+sqrt(e-sin(3pi/2))')).to.be.equal("sin(cos(3*pi-5))+sqrt(e-sin(3*pi/2))")
|
|
56
|
-
expect(new Shutingyard(ShutingyardMode.EXPRESSION).normalize('sin(cos(3picos(3pi)-5))+sqrt(e-sin(3pi/2))')).to.be.equal("sin(cos(3*pi*cos(3*pi)-5))+sqrt(e-sin(3*pi/2))")
|
|
57
|
-
})
|
|
58
|
-
});
|