pimath 0.0.125 → 0.0.126
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 +5 -5
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +192 -192
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +2404 -2404
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +1362 -1362
- package/dev/pimath.js +7945 -0
- package/dev/pimath.js.map +1 -0
- package/dist/pimath.js +192 -221
- package/dist/pimath.js.map +1 -1
- package/dist/pimath.min.js +1 -1
- package/dist/pimath.min.js.map +1 -1
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +78 -0
- package/docs/assets/main.js +59 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1383 -0
- package/docs/classes/Logicalset.Logicalset.html +217 -0
- package/docs/classes/Polynom.Rational.html +397 -0
- package/docs/classes/Vector-1.Vector.html +490 -0
- package/docs/classes/Vector.Point.html +337 -0
- package/docs/classes/algebra_equation.Equation.html +790 -0
- package/docs/classes/algebra_linearSystem.LinearSystem.html +404 -0
- package/docs/classes/algebra_monom.Monom.html +962 -0
- package/docs/classes/algebra_polynom.Polynom.html +1275 -0
- package/docs/classes/coefficients_fraction.Fraction.html +934 -0
- package/docs/classes/geometry_circle.Circle.html +472 -0
- package/docs/classes/geometry_line.Line.html +774 -0
- package/docs/classes/geometry_triangle.Triangle.html +429 -0
- package/docs/classes/numeric.Numeric.html +265 -0
- package/docs/classes/shutingyard.Shutingyard.html +250 -0
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +83 -0
- package/docs/enums/geometry_line.LinePropriety.html +97 -0
- package/docs/enums/shutingyard.ShutingyardMode.html +97 -0
- package/docs/enums/shutingyard.ShutingyardType.html +111 -0
- package/docs/index.html +63 -0
- package/docs/interfaces/algebra_equation.ISolution.html +105 -0
- package/docs/interfaces/algebra_polynom.IEuclidian.html +87 -0
- package/docs/interfaces/geometry_triangle.remarquableLines.html +163 -0
- package/docs/modules/Logicalset.html +65 -0
- package/docs/modules/Polynom.html +65 -0
- package/docs/modules/Vector-1.html +65 -0
- package/docs/modules/Vector.html +65 -0
- package/docs/modules/algebra_equation.html +69 -0
- package/docs/modules/algebra_linearSystem.html +61 -0
- package/docs/modules/algebra_monom.html +65 -0
- package/docs/modules/algebra_polynom.html +69 -0
- package/docs/modules/coefficients_fraction.html +65 -0
- package/docs/modules/geometry_circle.html +61 -0
- package/docs/modules/geometry_line.html +65 -0
- package/docs/modules/geometry_triangle.html +65 -0
- package/docs/modules/numeric.html +61 -0
- package/docs/modules/shutingyard.html +75 -0
- package/docs/types/algebra_monom.literalType.html +61 -0
- package/docs/types/algebra_polynom.PolynomParsingType.html +56 -0
- package/docs/types/coefficients_fraction.FractionParsingType.html +56 -0
- package/docs/types/shutingyard.Token.html +63 -0
- package/docs/types/shutingyard.tokenType.html +68 -0
- package/docs/variables/shutingyard.tokenConstant.html +61 -0
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +19 -19
- package/esm/maths/algebra/monom.js +66 -66
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +14 -14
- package/esm/maths/algebra/polynom.js +72 -50
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/numeric.js +3 -48
- package/esm/maths/numeric.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/maths/algebra/monom.ts +138 -130
- package/src/maths/algebra/polynom.ts +107 -85
- package/src/maths/numeric.ts +61 -90
- package/tests/algebra/linear.test.ts +1 -1
- package/tests/algebra/polynom.test.ts +152 -1
- package/tests/algebra/study.test.ts +1 -0
- package/tests/geometry/circle.test.ts +114 -130
- package/tests/geometry/line.test.ts +8 -17
|
@@ -67,6 +67,13 @@ describe('Polynom tests', () => {
|
|
|
67
67
|
expect(euclidian.reminder.tex).to.be.equal('12')
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
+
it('should reduce', () => {
|
|
71
|
+
let P = new Polynom('15x-19x+24+4x-12')
|
|
72
|
+
P.reduce()
|
|
73
|
+
expect(P.tex).to.be.equal('12')
|
|
74
|
+
|
|
75
|
+
})
|
|
76
|
+
|
|
70
77
|
it('should factorize the polynom', () => {
|
|
71
78
|
let P = new Polynom('x^2-5x+6')
|
|
72
79
|
|
|
@@ -99,7 +106,7 @@ describe('Polynom tests', () => {
|
|
|
99
106
|
expect(P2.texFactors).to.be.equal('-2x\\left( x+3 \\right)\\left( x-3 \\right)')
|
|
100
107
|
});
|
|
101
108
|
|
|
102
|
-
it('should detect if a polynom is factorized', function (){
|
|
109
|
+
it('should detect if a polynom is factorized', function () {
|
|
103
110
|
let P = new Polynom('x-1')
|
|
104
111
|
expect(P.isFactorized('x-1')).to.be.true
|
|
105
112
|
expect(P.isFactorized('x-2')).to.be.false
|
|
@@ -164,6 +171,12 @@ describe('Polynom parsing with rational power', () => {
|
|
|
164
171
|
})
|
|
165
172
|
})
|
|
166
173
|
|
|
174
|
+
describe("Polynom with multiple variables", () => {
|
|
175
|
+
it('should parse with multiple variables', () => {
|
|
176
|
+
const P = new Polynom('ax')
|
|
177
|
+
expect(P.display).to.be.equal('ax')
|
|
178
|
+
})
|
|
179
|
+
})
|
|
167
180
|
|
|
168
181
|
// describe("test simple", ()=>{
|
|
169
182
|
// it('should parce this one correctly', ()=>{
|
|
@@ -180,3 +193,141 @@ describe('Polynom parsing with rational power', () => {
|
|
|
180
193
|
// expect(P.degree().value).to.be.equal(0.5)
|
|
181
194
|
// })
|
|
182
195
|
// })
|
|
196
|
+
//
|
|
197
|
+
// describe('Polynom used as complex number', () => {
|
|
198
|
+
// let P = new Polynom('4+3i')
|
|
199
|
+
//
|
|
200
|
+
// P.pow(2)
|
|
201
|
+
//
|
|
202
|
+
// P.monoms.forEach(m => {
|
|
203
|
+
// const d = m.degree('i').value
|
|
204
|
+
// if (d >= 2) {
|
|
205
|
+
// if (d % 2 === 0) {
|
|
206
|
+
// m.coefficient = m.coefficient.multiply((-1) ** (d / 2))
|
|
207
|
+
// m.setLetter('i', 0)
|
|
208
|
+
// } else {
|
|
209
|
+
// m.coefficient = m.coefficient.multiply((-1) ** ((d - 1) / 2))
|
|
210
|
+
// m.setLetter('i', 1)
|
|
211
|
+
// }
|
|
212
|
+
// }
|
|
213
|
+
// })
|
|
214
|
+
// // console.log(P.reduce().tex)
|
|
215
|
+
//
|
|
216
|
+
// })
|
|
217
|
+
//
|
|
218
|
+
// describe("making my test", () => {
|
|
219
|
+
// let models = [
|
|
220
|
+
// {
|
|
221
|
+
// question: 'B \\cdot A^{K}=C',
|
|
222
|
+
// answer: {
|
|
223
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
|
|
224
|
+
// poly: (k: Polynom, p: Polynom) => k.clone()
|
|
225
|
+
// }
|
|
226
|
+
// },
|
|
227
|
+
// {
|
|
228
|
+
// question: 'B \\cdot A^{K}=C',
|
|
229
|
+
// answer: {
|
|
230
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
|
|
231
|
+
// poly: (k: Polynom, p: Polynom) => k.clone()
|
|
232
|
+
// }
|
|
233
|
+
// },
|
|
234
|
+
// {
|
|
235
|
+
// question: 'A^{K}=B \\cdot A^{P}',
|
|
236
|
+
// answer: {
|
|
237
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b),
|
|
238
|
+
// poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
|
|
239
|
+
// }
|
|
240
|
+
// },
|
|
241
|
+
// {
|
|
242
|
+
// question: 'A^{K}=B \\cdot A^{P}',
|
|
243
|
+
// answer: {
|
|
244
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b),
|
|
245
|
+
// poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
|
|
246
|
+
// }
|
|
247
|
+
// },
|
|
248
|
+
// {
|
|
249
|
+
// question: 'B \\cdot A^{K} = C \\cdot A^{P}',
|
|
250
|
+
// answer: {
|
|
251
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
|
|
252
|
+
// poly: (k: Polynom, p: Polynom) => k.clone().subtract(p)
|
|
253
|
+
// }
|
|
254
|
+
// },
|
|
255
|
+
// {
|
|
256
|
+
// question: 'B \\cdot A^{K} = \\frac{ C }{ A^{P} }',
|
|
257
|
+
// answer: {
|
|
258
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(c, b),
|
|
259
|
+
// poly: (k: Polynom, p: Polynom) => k.clone().add(p)
|
|
260
|
+
// }
|
|
261
|
+
// },
|
|
262
|
+
// {
|
|
263
|
+
// question: 'C \\cdot A^{K} - B = D',
|
|
264
|
+
// answer: {
|
|
265
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(d + b, c),
|
|
266
|
+
// poly: (k: Polynom, p: Polynom) => k.clone()
|
|
267
|
+
// }
|
|
268
|
+
// },
|
|
269
|
+
// {
|
|
270
|
+
// question: 'C \\cdot A^{K} - B = D \\cdot A^{P} ',
|
|
271
|
+
// answer: {
|
|
272
|
+
// log: (a: number, b: number, c: number, d: number, e: number) => new Fraction(b, c - e),
|
|
273
|
+
// poly: (k: Polynom, p: Polynom) => k.clone()
|
|
274
|
+
// }
|
|
275
|
+
// },
|
|
276
|
+
// ]
|
|
277
|
+
//
|
|
278
|
+
//
|
|
279
|
+
// for (let i = 0; i < 15; i++) {
|
|
280
|
+
// console.log(`{\\centering \\huge équations logarithmiques \\\\ }\n\nRésoudre les équations suivantes. Donner la réponse sous forme exacte et avec 4 décimales.`)
|
|
281
|
+
//
|
|
282
|
+
// console.log(`\\begin{enumerate}[(i),itemsep=4em]\n`)
|
|
283
|
+
//
|
|
284
|
+
// for (let m of models) {
|
|
285
|
+
// let a = PiMath.Random.number(2, 9),
|
|
286
|
+
// b = PiMath.Random.number(2, 9),
|
|
287
|
+
// c = PiMath.Random.number(2, 9),
|
|
288
|
+
// d = PiMath.Random.number(1, 9),
|
|
289
|
+
// e = PiMath.Random.number(1, c - 1),
|
|
290
|
+
// k = PiMath.Random.polynom({degree: 1}),
|
|
291
|
+
// p = PiMath.Random.polynom({degree: 1})
|
|
292
|
+
//
|
|
293
|
+
// if (k.monomByDegree(1).coefficient.isNegative()) {
|
|
294
|
+
// k.opposed()
|
|
295
|
+
// }
|
|
296
|
+
// if (p.monomByDegree(1).coefficient.isNegative()) {
|
|
297
|
+
// p.opposed()
|
|
298
|
+
// }
|
|
299
|
+
//
|
|
300
|
+
// let poly = m.answer.poly(k, p),
|
|
301
|
+
// pa = poly.monomByDegree(1).coefficient,
|
|
302
|
+
// pb = poly.monomByDegree(0).coefficient
|
|
303
|
+
//
|
|
304
|
+
// if (pa.isZero()) {
|
|
305
|
+
// k = k.add('x')
|
|
306
|
+
// poly = m.answer.poly(k, p),
|
|
307
|
+
// pa = poly.monomByDegree(1).coefficient,
|
|
308
|
+
// pb = poly.monomByDegree(0).coefficient
|
|
309
|
+
// }
|
|
310
|
+
//
|
|
311
|
+
// const question = m.question
|
|
312
|
+
// .replaceAll('A', a.toString())
|
|
313
|
+
// .replaceAll('B', b.toString())
|
|
314
|
+
// .replaceAll('C', c.toString())
|
|
315
|
+
// .replaceAll('D', d.toString())
|
|
316
|
+
// .replaceAll('K', k.tex)
|
|
317
|
+
// .replaceAll('P', p.tex)
|
|
318
|
+
//
|
|
319
|
+
//
|
|
320
|
+
// const log = m.answer.log(a, b, c, d, e).reduce()
|
|
321
|
+
// let answer = `\\log_{ ${a} }\\left( ${log.tex} \\right)`
|
|
322
|
+
// if (!pb.isZero()) answer = `${answer}${pb.clone().opposed().texWithSign}`
|
|
323
|
+
// if (!pa.isOne()) answer = `\\frac{ ${answer} }{ ${pa.tex} }`
|
|
324
|
+
//
|
|
325
|
+
// let value = ((Math.log10(log.value) / Math.log10(a) - pb.value) / pa.value).toFixed(4)
|
|
326
|
+
//
|
|
327
|
+
// console.log(`\\item \\(\\displaystyle ${question}\\) \\hfill \\( \\trou{ ${answer}=${value} } \\)`)
|
|
328
|
+
// }
|
|
329
|
+
//
|
|
330
|
+
// console.log(`\\end{enumerate}\n\\newpage`)
|
|
331
|
+
// }
|
|
332
|
+
//
|
|
333
|
+
// })
|
|
@@ -4,8 +4,6 @@ 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";
|
|
9
7
|
|
|
10
8
|
describe('Circle', function () {
|
|
11
9
|
it('should calculate the intersection of a circle and a line', function () {
|
|
@@ -66,134 +64,120 @@ describe('Circle', function () {
|
|
|
66
64
|
it('should calculate the circle from center and radius', function () {
|
|
67
65
|
let circle = new Circle("x^2+6x+y^2-8y+12=0")
|
|
68
66
|
|
|
69
|
-
console.log(circle.tex)
|
|
67
|
+
// console.log(circle.tex)
|
|
70
68
|
})
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
})
|
|
70
|
+
|
|
71
|
+
// it('temp tests', () => {
|
|
72
|
+
// for (let i = 0; i < 30; i++) {
|
|
73
|
+
// let A = Random.Geometry.point({axis: false}),
|
|
74
|
+
// B = Random.Geometry.point({axis: false})
|
|
75
|
+
//
|
|
76
|
+
// if (Random.bool()) {
|
|
77
|
+
// B.x = new Fraction().zero()
|
|
78
|
+
// } else {
|
|
79
|
+
// B.y = new Fraction().zero()
|
|
80
|
+
// }
|
|
81
|
+
//
|
|
82
|
+
// const c1 = new Circle(A, Random.number(1, 10)),
|
|
83
|
+
// c2 = new Circle(B, Random.number(1, 10))
|
|
84
|
+
//
|
|
85
|
+
// 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.
|
|
86
|
+
// \\begin{enumerate}[label=\\Alph*]
|
|
87
|
+
// \\item \\( (\\Gamma_1): ${c1.developed}\\) \\iftoggle{master}{\\(${c1.tex}\\)}{}
|
|
88
|
+
// \\item \\( (\\Gamma_2): ${c2.developed}\\) \\iftoggle{master}{\\(${c2.tex}\\)}{}
|
|
89
|
+
// \\end{enumerate}
|
|
90
|
+
// \\vfill
|
|
91
|
+
// ${i % 2 === 1 ? '\\newpage' : ''}
|
|
92
|
+
// `)
|
|
93
|
+
// }
|
|
94
|
+
// })
|
|
95
|
+
//
|
|
96
|
+
// it('temp tests 2', () => {
|
|
97
|
+
// const q = `(I): Soit \\(\\Gamma_1\\) et \\(\\Gamma_2\\) deux cercles. Déterminer leur position relative à l'aide des informations ci-dessous.
|
|
98
|
+
//
|
|
99
|
+
// \\[(\\Gamma_1): @G1 \\qquad (\\Gamma_2): @G2 \\]
|
|
100
|
+
// \\[\\trou{@R1} \\]
|
|
101
|
+
//
|
|
102
|
+
// \\vspace{3cm}
|
|
103
|
+
// (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.\\\\
|
|
104
|
+
// Préciser la position relative entre \\(\\Gamma_3\\) et \\(\\Gamma_4\\)
|
|
105
|
+
// \\[ \\trou{@R2a} \\]
|
|
106
|
+
// \\[ \\trou{@R2b} \\]
|
|
107
|
+
// `
|
|
108
|
+
//
|
|
109
|
+
// for (let i = 0; i < 30; i++) {
|
|
110
|
+
// let A = Random.Geometry.point({axis: false}),
|
|
111
|
+
// triplet = Random.item(Numeric.pythagoricianTripletsWithTarget(
|
|
112
|
+
// Random.item([5, 13, 17, 25, 29, 37, 41])
|
|
113
|
+
// ).filter(tr => {
|
|
114
|
+
// // remove all items with zero values.
|
|
115
|
+
// return tr.every(x => x !== 0)
|
|
116
|
+
// })),
|
|
117
|
+
// B = new Point(
|
|
118
|
+
// A.x.value + triplet[0],
|
|
119
|
+
// A.y.value + triplet[1]
|
|
120
|
+
// ),
|
|
121
|
+
// delta = Random.number(2, triplet[2] - 1),
|
|
122
|
+
// positionRelative = ['extérieure', 'intérieure', 'sécante', 'disjointe'][i % 4],
|
|
123
|
+
// // positionRelative = Random.item(['extérieure', 'intérieure', 'sécante', 'disjointe']),
|
|
124
|
+
// c1: Circle, c2: Circle
|
|
125
|
+
//
|
|
126
|
+
// if (positionRelative === 'extérieure') {
|
|
127
|
+
// c1 = new Circle(A, triplet[2] - delta)
|
|
128
|
+
// c2 = new Circle(B, delta)
|
|
129
|
+
// } else if (positionRelative === 'intérieure') {
|
|
130
|
+
// c1 = new Circle(A, triplet[2] + delta)
|
|
131
|
+
// c2 = new Circle(B, delta)
|
|
132
|
+
// } else if (positionRelative === 'sécante') {
|
|
133
|
+
// c1 = new Circle(A, triplet[2] + delta - Random.number(1, delta - 1))
|
|
134
|
+
// c2 = new Circle(B, delta)
|
|
135
|
+
// } else if (positionRelative === 'disjointe') {
|
|
136
|
+
// c1 = new Circle(A, triplet[2] + delta + 1)
|
|
137
|
+
// c2 = new Circle(B, delta)
|
|
138
|
+
// }
|
|
139
|
+
//
|
|
140
|
+
// 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}} `
|
|
141
|
+
//
|
|
142
|
+
//
|
|
143
|
+
// let C = Random.Geometry.point({axis: false}),
|
|
144
|
+
// r1 = Random.number(2, 10),
|
|
145
|
+
// c3 = new Circle(C, r1),
|
|
146
|
+
// // Get a random number from 2 to 10 that is not equal to r1
|
|
147
|
+
// r2 = Random.number(2, 10, [r1]),
|
|
148
|
+
// axis = Random.item(['abscisse', 'ordonnée']),
|
|
149
|
+
// centers: Point[] = []
|
|
150
|
+
//
|
|
151
|
+
// const c3x = c3.center.x.value,
|
|
152
|
+
// c3y = c3.center.y.value
|
|
153
|
+
// if (axis === 'abscisse') {
|
|
154
|
+
//
|
|
155
|
+
// centers = [
|
|
156
|
+
// new Point(c3x, c3y - (r1 + r2)),
|
|
157
|
+
// new Point(c3x, c3y - (r2 - r1)),
|
|
158
|
+
// new Point(c3x, c3y - (r1 - r2)),
|
|
159
|
+
// new Point(c3x, c3y + (r1 + r2))
|
|
160
|
+
// ]
|
|
161
|
+
// } else {
|
|
162
|
+
// centers = [
|
|
163
|
+
// new Point(c3x - (r1 + r2), c3y),
|
|
164
|
+
// new Point(c3x - (r2 - r1), c3y),
|
|
165
|
+
// new Point(c3x - (r1 - r2), c3y),
|
|
166
|
+
// new Point(c3x + (r1 + r2), c3y)
|
|
167
|
+
// ]
|
|
168
|
+
// }
|
|
169
|
+
//
|
|
170
|
+
// console.log(`(exercice ${i + 1}): ` + q
|
|
171
|
+
// .replaceAll('@G1', c1.tex)
|
|
172
|
+
// .replaceAll('@R1', R1)
|
|
173
|
+
// .replaceAll('@G2', c2.tex)
|
|
174
|
+
// .replaceAll('@G3', c3.developed)
|
|
175
|
+
// .replaceAll('@RAYON', r2.toString())
|
|
176
|
+
// .replaceAll('@AXE', axis)
|
|
177
|
+
// .replaceAll('@R2a', centers.slice(0, 2).map(x => new Circle(x, r2).tex).join(' \\qquad '))
|
|
178
|
+
// .replaceAll('@R2b', centers.slice(2, 4).map(x => new Circle(x, r2).tex).join(' \\qquad '))
|
|
179
|
+
// + '\\vfill' + (i % 2 === 1 ? '\\newpage' : '')
|
|
180
|
+
// )
|
|
181
|
+
// }
|
|
182
|
+
// })
|
|
199
183
|
});
|
|
@@ -2,44 +2,35 @@ import {describe} from "mocha";
|
|
|
2
2
|
import {Line} from "../../src/maths/geometry/line";
|
|
3
3
|
import {Point} from "../../src/maths/geometry/point";
|
|
4
4
|
import {expect} from "chai";
|
|
5
|
-
import {Equation} from "../../src/maths/algebra/equation";
|
|
6
|
-
import {Polynom} from "../../src/maths/algebra/polynom";
|
|
7
|
-
import {Monom} from "../../src/maths/algebra/monom";
|
|
8
5
|
|
|
9
6
|
describe('Geometry Line', function () {
|
|
10
7
|
it('should evaluate coordinates', function () {
|
|
11
8
|
let L = new Line('3x-4y+5=0')
|
|
12
9
|
|
|
13
10
|
let y = L.getValueAtX(0)
|
|
14
|
-
|
|
11
|
+
expect(y.display).to.be.equal('5/4')
|
|
15
12
|
});
|
|
16
13
|
|
|
17
14
|
it('should output nice Tex', function () {
|
|
18
15
|
let L = new Line('9x-8y-96=0'),
|
|
19
16
|
tex = L.tex
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
console.log(tex.system)
|
|
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)
|
|
27
23
|
});
|
|
28
24
|
|
|
29
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
|
|
30
28
|
let L = new Line(3, 2, 1)
|
|
31
29
|
|
|
32
30
|
let P1 = new Point(-2, 3),
|
|
33
31
|
P2 = new Point(-3, 4)
|
|
34
32
|
expect(L.isOnLine(P1)).to.be.false
|
|
35
33
|
expect(L.isOnLine(P2)).to.be.true
|
|
36
|
-
|
|
37
|
-
console.log(
|
|
38
|
-
(new Polynom(L.OA.y)
|
|
39
|
-
.add(new Monom(L.d.y).multiply(new Monom('k'))))
|
|
40
|
-
.reorder('k', true)
|
|
41
|
-
.tex
|
|
42
|
-
)
|
|
43
34
|
})
|
|
44
35
|
|
|
45
36
|
});
|