pimath 0.0.125 → 0.0.127
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 +97 -82
- package/src/maths/geometry/line.ts +22 -25
- package/src/maths/geometry/point.ts +43 -29
- package/src/maths/numeric.ts +61 -90
- package/src/maths/randomization/random.ts +7 -0
- package/src/maths/randomization/rndGeometryCircle.ts +50 -0
- package/src/maths/randomization/rndTypes.ts +10 -4
- package/tests/algebra/linear.test.ts +1 -1
- package/tests/algebra/polynom.test.ts +162 -1
- package/tests/algebra/study.test.ts +1 -0
- package/tests/geometry/circle.test.ts +320 -115
- package/tests/geometry/line.test.ts +8 -17
- package/tests/numeric.test.ts +19 -3
|
@@ -5,7 +5,7 @@ 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
7
|
import {Random} from "../../src/maths/randomization/random";
|
|
8
|
-
import {
|
|
8
|
+
import {Vector} from "../../src/maths/geometry/vector";
|
|
9
9
|
|
|
10
10
|
describe('Circle', function () {
|
|
11
11
|
it('should calculate the intersection of a circle and a line', function () {
|
|
@@ -66,134 +66,339 @@ describe('Circle', function () {
|
|
|
66
66
|
it('should calculate the circle from center and radius', function () {
|
|
67
67
|
let circle = new Circle("x^2+6x+y^2-8y+12=0")
|
|
68
68
|
|
|
69
|
-
console.log(circle.tex)
|
|
69
|
+
// console.log(circle.tex)
|
|
70
70
|
})
|
|
71
71
|
|
|
72
|
-
it('
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
+
}
|
|
80
104
|
|
|
81
|
-
console.log(A.tex, B.tex)
|
|
82
105
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
return {
|
|
107
|
+
circle: c,
|
|
108
|
+
tangents: [t1, t2],
|
|
109
|
+
point: I
|
|
110
|
+
}
|
|
111
|
+
}
|
|
86
112
|
|
|
87
|
-
it('temp tests', () => {
|
|
88
113
|
for (let i = 0; i < 30; i++) {
|
|
89
|
-
let
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
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
|
+
`)
|
|
97
124
|
|
|
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
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
|
+
*/
|
|
110
161
|
})
|
|
111
|
-
|
|
112
|
-
|
|
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++) {
|
|
162
|
+
it('tangentes temp tests', () => {
|
|
163
|
+
function makeCircle(): { circle: Circle, point: Point, tangent: Line, symetric: Line } {
|
|
126
164
|
let A = Random.Geometry.point({axis: false}),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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)
|
|
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
|
+
}
|
|
154
178
|
}
|
|
155
179
|
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
]
|
|
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
|
|
184
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
|
+
`)
|
|
185
214
|
|
|
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
215
|
}
|
|
198
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
|
+
// })
|
|
199
404
|
});
|
|
@@ -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
|
});
|
package/tests/numeric.test.ts
CHANGED
|
@@ -8,7 +8,7 @@ describe('Numeric', () => { // the tests container
|
|
|
8
8
|
expect(Numeric.numberCorrection(a)).to.be.equal(0.3)
|
|
9
9
|
const b = Math.pow(10, -5)
|
|
10
10
|
|
|
11
|
-
expect(Numeric.numberCorrection(b, 1,12)).to.be.equal(0.00001)
|
|
11
|
+
expect(Numeric.numberCorrection(b, 1, 12)).to.be.equal(0.00001)
|
|
12
12
|
})
|
|
13
13
|
|
|
14
14
|
|
|
@@ -21,7 +21,23 @@ describe('Numeric', () => { // the tests container
|
|
|
21
21
|
})
|
|
22
22
|
|
|
23
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'])
|
|
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
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
|
+
})
|
|
27
43
|
});
|