pimath 0.0.127 → 0.0.129

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.
Files changed (212) hide show
  1. package/dist/main.d.ts +39 -0
  2. package/{esm → dist}/maths/algebra/equation.d.ts +11 -10
  3. package/{esm → dist}/maths/algebra/linearSystem.d.ts +5 -4
  4. package/{esm → dist}/maths/algebra/monom.d.ts +5 -4
  5. package/{esm → dist}/maths/algebra/polynom.d.ts +11 -13
  6. package/{esm → dist}/maths/algebra/rational.d.ts +7 -9
  7. package/dist/maths/algebra/study/rationalStudy.d.ts +14 -0
  8. package/{esm → dist}/maths/algebra/study.d.ts +4 -7
  9. package/{esm → dist}/maths/geometry/circle.d.ts +9 -8
  10. package/{esm → dist}/maths/geometry/line.d.ts +17 -14
  11. package/{esm → dist}/maths/geometry/point.d.ts +11 -9
  12. package/{esm → dist}/maths/geometry/triangle.d.ts +4 -3
  13. package/{esm → dist}/maths/geometry/vector.d.ts +7 -10
  14. package/{esm → dist}/maths/randomization/random.d.ts +10 -7
  15. package/{esm → dist}/maths/randomization/rndFraction.d.ts +4 -3
  16. package/dist/maths/randomization/rndGeometryCircle.d.ts +13 -0
  17. package/{esm → dist}/maths/randomization/rndGeometryLine.d.ts +4 -3
  18. package/{esm → dist}/maths/randomization/rndGeometryPoint.d.ts +4 -3
  19. package/{esm → dist}/maths/randomization/rndMonom.d.ts +5 -4
  20. package/{esm → dist}/maths/randomization/rndPolynom.d.ts +5 -4
  21. package/{esm → dist}/maths/randomization/rndTypes.d.ts +7 -1
  22. package/dist/pimath.js +4239 -7819
  23. package/package.json +13 -7
  24. package/.eslintrc.js +0 -24
  25. package/.idea/$CACHE_FILE$ +0 -6
  26. package/.idea/PI.iml +0 -14
  27. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  28. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  29. package/.idea/misc.xml +0 -6
  30. package/.idea/modules.xml +0 -8
  31. package/.idea/php.xml +0 -19
  32. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +0 -192
  33. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]1/shelved.patch +0 -0
  34. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30__Default_Changelist_.xml +0 -4
  35. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +0 -2404
  36. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +0 -4
  37. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +0 -1362
  38. package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +0 -4
  39. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]/shelved.patch +0 -90
  40. package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_.xml +0 -4
  41. package/.idea/vcs.xml +0 -6
  42. package/dev/pimath.js +0 -7945
  43. package/dev/pimath.js.map +0 -1
  44. package/dist/pimath.js.map +0 -1
  45. package/dist/pimath.min.js +0 -2
  46. package/dist/pimath.min.js.map +0 -1
  47. package/docs/.nojekyll +0 -1
  48. package/docs/assets/highlight.css +0 -78
  49. package/docs/assets/main.js +0 -59
  50. package/docs/assets/navigation.js +0 -1
  51. package/docs/assets/search.js +0 -1
  52. package/docs/assets/style.css +0 -1383
  53. package/docs/classes/Logicalset.Logicalset.html +0 -217
  54. package/docs/classes/Polynom.Rational.html +0 -397
  55. package/docs/classes/Vector-1.Vector.html +0 -490
  56. package/docs/classes/Vector.Point.html +0 -337
  57. package/docs/classes/algebra_equation.Equation.html +0 -790
  58. package/docs/classes/algebra_linearSystem.LinearSystem.html +0 -404
  59. package/docs/classes/algebra_monom.Monom.html +0 -962
  60. package/docs/classes/algebra_polynom.Polynom.html +0 -1275
  61. package/docs/classes/coefficients_fraction.Fraction.html +0 -934
  62. package/docs/classes/geometry_circle.Circle.html +0 -472
  63. package/docs/classes/geometry_line.Line.html +0 -774
  64. package/docs/classes/geometry_triangle.Triangle.html +0 -429
  65. package/docs/classes/numeric.Numeric.html +0 -265
  66. package/docs/classes/shutingyard.Shutingyard.html +0 -250
  67. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +0 -83
  68. package/docs/enums/geometry_line.LinePropriety.html +0 -97
  69. package/docs/enums/shutingyard.ShutingyardMode.html +0 -97
  70. package/docs/enums/shutingyard.ShutingyardType.html +0 -111
  71. package/docs/index.html +0 -63
  72. package/docs/interfaces/algebra_equation.ISolution.html +0 -105
  73. package/docs/interfaces/algebra_polynom.IEuclidian.html +0 -87
  74. package/docs/interfaces/geometry_triangle.remarquableLines.html +0 -163
  75. package/docs/modules/Logicalset.html +0 -65
  76. package/docs/modules/Polynom.html +0 -65
  77. package/docs/modules/Vector-1.html +0 -65
  78. package/docs/modules/Vector.html +0 -65
  79. package/docs/modules/algebra_equation.html +0 -69
  80. package/docs/modules/algebra_linearSystem.html +0 -61
  81. package/docs/modules/algebra_monom.html +0 -65
  82. package/docs/modules/algebra_polynom.html +0 -69
  83. package/docs/modules/coefficients_fraction.html +0 -65
  84. package/docs/modules/geometry_circle.html +0 -61
  85. package/docs/modules/geometry_line.html +0 -65
  86. package/docs/modules/geometry_triangle.html +0 -65
  87. package/docs/modules/numeric.html +0 -61
  88. package/docs/modules/shutingyard.html +0 -75
  89. package/docs/types/algebra_monom.literalType.html +0 -61
  90. package/docs/types/algebra_polynom.PolynomParsingType.html +0 -56
  91. package/docs/types/coefficients_fraction.FractionParsingType.html +0 -56
  92. package/docs/types/shutingyard.Token.html +0 -63
  93. package/docs/types/shutingyard.tokenType.html +0 -68
  94. package/docs/variables/shutingyard.tokenConstant.html +0 -61
  95. package/esm/index.d.ts +0 -38
  96. package/esm/index.js +0 -44
  97. package/esm/index.js.map +0 -1
  98. package/esm/maths/algebra/equation.js +0 -797
  99. package/esm/maths/algebra/equation.js.map +0 -1
  100. package/esm/maths/algebra/linearSystem.js +0 -279
  101. package/esm/maths/algebra/linearSystem.js.map +0 -1
  102. package/esm/maths/algebra/logicalset.js +0 -158
  103. package/esm/maths/algebra/logicalset.js.map +0 -1
  104. package/esm/maths/algebra/monom.js +0 -909
  105. package/esm/maths/algebra/monom.js.map +0 -1
  106. package/esm/maths/algebra/polynom.js +0 -1305
  107. package/esm/maths/algebra/polynom.js.map +0 -1
  108. package/esm/maths/algebra/rational.js +0 -195
  109. package/esm/maths/algebra/rational.js.map +0 -1
  110. package/esm/maths/algebra/study/rationalStudy.d.ts +0 -28
  111. package/esm/maths/algebra/study/rationalStudy.js +0 -244
  112. package/esm/maths/algebra/study/rationalStudy.js.map +0 -1
  113. package/esm/maths/algebra/study.js +0 -380
  114. package/esm/maths/algebra/study.js.map +0 -1
  115. package/esm/maths/coefficients/fraction.js +0 -517
  116. package/esm/maths/coefficients/fraction.js.map +0 -1
  117. package/esm/maths/coefficients/nthRoot.js +0 -137
  118. package/esm/maths/coefficients/nthRoot.js.map +0 -1
  119. package/esm/maths/geometry/circle.js +0 -324
  120. package/esm/maths/geometry/circle.js.map +0 -1
  121. package/esm/maths/geometry/line.js +0 -485
  122. package/esm/maths/geometry/line.js.map +0 -1
  123. package/esm/maths/geometry/point.js +0 -167
  124. package/esm/maths/geometry/point.js.map +0 -1
  125. package/esm/maths/geometry/triangle.js +0 -276
  126. package/esm/maths/geometry/triangle.js.map +0 -1
  127. package/esm/maths/geometry/vector.js +0 -198
  128. package/esm/maths/geometry/vector.js.map +0 -1
  129. package/esm/maths/numeric.js +0 -136
  130. package/esm/maths/numeric.js.map +0 -1
  131. package/esm/maths/numexp.js +0 -186
  132. package/esm/maths/numexp.js.map +0 -1
  133. package/esm/maths/randomization/random.js +0 -79
  134. package/esm/maths/randomization/random.js.map +0 -1
  135. package/esm/maths/randomization/randomCore.js +0 -22
  136. package/esm/maths/randomization/randomCore.js.map +0 -1
  137. package/esm/maths/randomization/rndFraction.js +0 -44
  138. package/esm/maths/randomization/rndFraction.js.map +0 -1
  139. package/esm/maths/randomization/rndGeometryLine.js +0 -46
  140. package/esm/maths/randomization/rndGeometryLine.js.map +0 -1
  141. package/esm/maths/randomization/rndGeometryPoint.js +0 -61
  142. package/esm/maths/randomization/rndGeometryPoint.js.map +0 -1
  143. package/esm/maths/randomization/rndHelpers.js +0 -98
  144. package/esm/maths/randomization/rndHelpers.js.map +0 -1
  145. package/esm/maths/randomization/rndMonom.js +0 -53
  146. package/esm/maths/randomization/rndMonom.js.map +0 -1
  147. package/esm/maths/randomization/rndPolynom.js +0 -75
  148. package/esm/maths/randomization/rndPolynom.js.map +0 -1
  149. package/esm/maths/randomization/rndTypes.js +0 -3
  150. package/esm/maths/randomization/rndTypes.js.map +0 -1
  151. package/esm/maths/shutingyard.js +0 -443
  152. package/esm/maths/shutingyard.js.map +0 -1
  153. package/public/demo.css +0 -3
  154. package/public/index.html +0 -283
  155. package/public/matrices.html +0 -100
  156. package/public/playground.html +0 -168
  157. package/src/index.ts +0 -42
  158. package/src/maths/algebra/equation.ts +0 -897
  159. package/src/maths/algebra/linearSystem.ts +0 -370
  160. package/src/maths/algebra/logicalset.ts +0 -183
  161. package/src/maths/algebra/monom.ts +0 -1028
  162. package/src/maths/algebra/polynom.ts +0 -1537
  163. package/src/maths/algebra/rational.ts +0 -240
  164. package/src/maths/algebra/study/rationalStudy.ts +0 -287
  165. package/src/maths/algebra/study.ts +0 -506
  166. package/src/maths/coefficients/fraction.ts +0 -593
  167. package/src/maths/coefficients/nthRoot.ts +0 -148
  168. package/src/maths/geometry/circle.ts +0 -382
  169. package/src/maths/geometry/line.ts +0 -604
  170. package/src/maths/geometry/point.ts +0 -215
  171. package/src/maths/geometry/triangle.ts +0 -368
  172. package/src/maths/geometry/vector.ts +0 -242
  173. package/src/maths/numeric.ts +0 -162
  174. package/src/maths/numexp.ts +0 -184
  175. package/src/maths/randomization/random.ts +0 -80
  176. package/src/maths/randomization/randomCore.ts +0 -19
  177. package/src/maths/randomization/rndFraction.ts +0 -47
  178. package/src/maths/randomization/rndGeometryCircle.ts +0 -50
  179. package/src/maths/randomization/rndGeometryLine.ts +0 -53
  180. package/src/maths/randomization/rndGeometryPoint.ts +0 -69
  181. package/src/maths/randomization/rndHelpers.ts +0 -107
  182. package/src/maths/randomization/rndMonom.ts +0 -57
  183. package/src/maths/randomization/rndPolynom.ts +0 -90
  184. package/src/maths/randomization/rndTypes.ts +0 -43
  185. package/src/maths/shutingyard.ts +0 -496
  186. package/tests/algebra/equation.test.ts +0 -64
  187. package/tests/algebra/linear.test.ts +0 -58
  188. package/tests/algebra/monom.test.ts +0 -78
  189. package/tests/algebra/polynom.test.ts +0 -343
  190. package/tests/algebra/rationnal.test.ts +0 -64
  191. package/tests/algebra/study.test.ts +0 -48
  192. package/tests/coefficients/fraction.test.ts +0 -131
  193. package/tests/custom.test.ts +0 -33
  194. package/tests/geometry/circle.test.ts +0 -404
  195. package/tests/geometry/line.test.ts +0 -36
  196. package/tests/numeric.test.ts +0 -43
  197. package/tests/numexp.test.ts +0 -89
  198. package/tests/shutingyard.test.ts +0 -58
  199. package/tsconfig.json +0 -41
  200. package/tsconfig.testing.json +0 -28
  201. package/typedoc.katex.js +0 -11
  202. package/webpack-production-min.config.js +0 -26
  203. package/webpack-production.config.js +0 -26
  204. package/webpack.config.js +0 -26
  205. package/{esm → dist}/maths/algebra/logicalset.d.ts +6 -6
  206. package/{esm → dist}/maths/coefficients/fraction.d.ts +0 -0
  207. package/{esm → dist}/maths/coefficients/nthRoot.d.ts +0 -0
  208. package/{esm → dist}/maths/numeric.d.ts +0 -0
  209. package/{esm → dist}/maths/numexp.d.ts +3 -3
  210. /package/{esm → dist}/maths/randomization/randomCore.d.ts +0 -0
  211. /package/{esm → dist}/maths/randomization/rndHelpers.d.ts +0 -0
  212. /package/{esm → dist}/maths/shutingyard.d.ts +0 -0
@@ -1,33 +0,0 @@
1
- // describe('Custom test', () => { // the tests container
2
- // it('Build sqrt value', () => {
3
- //
4
- // let a = 1, b = 27, c = 50
5
- //
6
- // a = Random.number(2,20)
7
- // b = Random.number(2,20)
8
- // c = Random.number(2,20)
9
- //
10
- // let nthB = new NthRoot(b).reduce(),
11
- // nthC = new NthRoot(c).reduce(),
12
- // nthD = new NthRoot(nthB.radical * nthC.radical).reduce(),
13
- // F = new Fraction(a*nthB.coefficient*nthD.coefficient, nthC.radical*nthC.coefficient).reduce(),
14
- // answer = ''
15
- //
16
- // if(F.numerator>1){
17
- // answer = `${F.numerator}`
18
- // }
19
- // if(nthD.radical>1){
20
- // answer = `${answer}sqrt${nthD.radical}`
21
- // }
22
- // if(F.denominator>1){
23
- // answer = `${answer}/${F.denominator}`
24
- // }
25
- // console.log(`${a}sqrt${b}/sqrt${c}`, answer)
26
- // })
27
- //
28
- // it('should generate a line', function () {
29
- // let L = Random.Geometry.line({
30
- // A: {x: 3, y: 7}
31
- // })
32
- // });
33
- // });
@@ -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
- });
@@ -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
- });
@@ -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
- });