pimath 0.0.33 → 0.0.36
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/pi.js +6468 -1
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +2 -0
- package/dist/pi.min.js.map +1 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/algebra.Equation.html +9 -9
- package/docs/classes/algebra.LinearSystem.html +1 -1
- package/docs/classes/algebra.Logicalset.html +2 -2
- package/docs/classes/algebra.Monom.html +37 -37
- package/docs/classes/algebra.Polynom.html +10 -10
- package/docs/classes/algebra.PolynomExpFactor.html +1 -1
- package/docs/classes/algebra.PolynomExpProduct.html +1 -1
- package/docs/classes/algebra.Rational.html +2 -2
- package/docs/classes/coefficients.Fraction.html +4 -4
- package/docs/classes/coefficients.Nthroot.html +1 -1
- package/docs/classes/geometry.Circle.html +2 -2
- package/docs/classes/geometry.Line.html +2 -2
- package/docs/classes/geometry.Point.html +1 -1
- package/docs/classes/geometry.Triangle.html +5 -5
- package/docs/classes/geometry.Vector.html +1 -1
- package/docs/classes/numeric.Numeric.html +5 -5
- package/docs/classes/shutingyard.Shutingyard.html +4 -4
- package/docs/enums/geometry.LinePropriety.html +1 -0
- package/docs/enums/shutingyard.ShutingyardMode.html +1 -1
- package/docs/enums/shutingyard.ShutingyardType.html +1 -1
- package/docs/interfaces/geometry.remarquableLines.html +1 -1
- package/docs/modules/algebra.html +1 -1
- package/docs/modules/coefficients.html +1 -1
- package/docs/modules/geometry.html +1 -1
- package/docs/modules/random.Random.html +1 -1
- package/docs/modules/random.html +1 -1
- package/docs/modules/shutingyard.html +1 -1
- package/esm/main.d.ts +41 -1
- package/esm/main.js +34 -20
- package/esm/main.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +63 -18
- package/esm/maths/algebra/equation.js +599 -503
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +1 -1
- package/esm/maths/algebra/linearSystem.js +157 -104
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.d.ts +11 -0
- package/esm/maths/algebra/logicalset.js +18 -6
- package/esm/maths/algebra/logicalset.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +142 -1
- package/esm/maths/algebra/monom.js +633 -405
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +52 -3
- package/esm/maths/algebra/polynom.js +1003 -720
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.d.ts +13 -1
- package/esm/maths/algebra/rational.js +98 -83
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +18 -0
- package/esm/maths/coefficients/fraction.js +390 -332
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/nthroot.d.ts +3 -0
- package/esm/maths/coefficients/nthroot.js +48 -33
- package/esm/maths/coefficients/nthroot.js.map +1 -1
- package/esm/maths/expressions/numexp.js +13 -5
- package/esm/maths/expressions/numexp.js.map +1 -1
- package/esm/maths/expressions/polynomexp.bkp.d.ts +2 -2
- package/esm/maths/expressions/polynomexp.bkp.js +95 -95
- package/esm/maths/expressions/polynomexp.bkp.js.map +1 -1
- package/esm/maths/expressions/polynomexp.d.ts +2 -2
- package/esm/maths/expressions/polynomexp.js +27 -14
- package/esm/maths/expressions/polynomexp.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +20 -8
- package/esm/maths/geometry/circle.js +148 -50
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +11 -4
- package/esm/maths/geometry/line.js +251 -193
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +13 -1
- package/esm/maths/geometry/point.js +124 -76
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +23 -1
- package/esm/maths/geometry/triangle.js +197 -158
- package/esm/maths/geometry/triangle.js.map +1 -1
- package/esm/maths/geometry/vector.d.ts +5 -1
- package/esm/maths/geometry/vector.js +139 -115
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/numeric.d.ts +17 -0
- package/esm/maths/numeric.js +40 -0
- package/esm/maths/numeric.js.map +1 -1
- package/esm/maths/{random/index.d.ts → randomization/random.d.ts} +3 -2
- package/esm/maths/{random/index.js → randomization/random.js} +6 -2
- package/esm/maths/randomization/random.js.map +1 -0
- package/esm/maths/{random → randomization}/randomCore.d.ts +0 -0
- package/esm/maths/randomization/randomCore.js +22 -0
- package/esm/maths/randomization/randomCore.js.map +1 -0
- package/esm/maths/{random → randomization}/rndFraction.d.ts +4 -1
- package/esm/maths/randomization/rndFraction.js +40 -0
- package/esm/maths/randomization/rndFraction.js.map +1 -0
- package/esm/maths/randomization/rndHelpers.d.ts +25 -0
- package/esm/maths/{random → randomization}/rndHelpers.js +20 -0
- package/esm/maths/randomization/rndHelpers.js.map +1 -0
- package/esm/maths/{random → randomization}/rndMonom.d.ts +4 -1
- package/esm/maths/randomization/rndMonom.js +53 -0
- package/esm/maths/randomization/rndMonom.js.map +1 -0
- package/esm/maths/{random → randomization}/rndPolynom.d.ts +4 -1
- package/esm/maths/randomization/rndPolynom.js +75 -0
- package/esm/maths/randomization/rndPolynom.js.map +1 -0
- package/esm/maths/{random → randomization}/rndTypes.d.ts +0 -0
- package/esm/maths/{random → randomization}/rndTypes.js +0 -0
- package/esm/maths/randomization/rndTypes.js.map +1 -0
- package/esm/maths/shutingyard.d.ts +21 -0
- package/esm/maths/shutingyard.js +86 -9
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +2 -2
- package/public/index.html +47 -0
- package/src/main.ts +17 -15
- package/src/maths/algebra/equation.ts +144 -129
- package/src/maths/algebra/linearSystem.ts +2 -2
- package/src/maths/algebra/monom.ts +1 -1
- package/src/maths/algebra/polynom.ts +136 -136
- package/src/maths/algebra/rational.ts +1 -1
- package/src/maths/expressions/numexp.ts +1 -1
- package/src/maths/expressions/polynomexp.bkp.ts +2 -2
- package/src/maths/expressions/polynomexp.ts +2 -2
- package/src/maths/geometry/circle.ts +172 -77
- package/src/maths/geometry/line.ts +4 -3
- package/src/maths/geometry/point.ts +26 -3
- package/src/maths/geometry/triangle.ts +1 -1
- package/src/maths/geometry/vector.ts +1 -1
- package/src/maths/numeric.ts +15 -0
- package/src/maths/{random/index.ts → randomization/random.ts} +3 -2
- package/src/maths/{random → randomization}/randomCore.ts +0 -0
- package/src/maths/{random → randomization}/rndFraction.ts +2 -2
- package/src/maths/{random → randomization}/rndHelpers.ts +0 -0
- package/src/maths/{random → randomization}/rndMonom.ts +2 -2
- package/src/maths/{random → randomization}/rndPolynom.ts +3 -3
- package/src/maths/{random → randomization}/rndTypes.ts +0 -0
- package/tests/algebra/monom.test.ts +1 -1
- package/tests/algebra/polynom.test.ts +8 -9
- package/tests/geometry/circle.test.ts +33 -0
- package/tsconfig.json +2 -2
- package/webpack-production-min.config.js +26 -0
- package/webpack-production.config.js +1 -1
- package/dev/pi.js +0 -5392
- package/dev/pi.js.map +0 -1
- package/esm/maths/algebra/index.d.ts +0 -7
- package/esm/maths/algebra/index.js +0 -20
- package/esm/maths/algebra/index.js.map +0 -1
- package/esm/maths/coefficients/index.d.ts +0 -2
- package/esm/maths/coefficients/index.js +0 -15
- package/esm/maths/coefficients/index.js.map +0 -1
- package/esm/maths/geometry/index.d.ts +0 -5
- package/esm/maths/geometry/index.js +0 -18
- package/esm/maths/geometry/index.js.map +0 -1
- package/esm/maths/random/index.js.map +0 -1
- package/esm/maths/random/randomCore.js +0 -22
- package/esm/maths/random/randomCore.js.map +0 -1
- package/esm/maths/random/rndFraction.js +0 -37
- package/esm/maths/random/rndFraction.js.map +0 -1
- package/esm/maths/random/rndHelpers.d.ts +0 -8
- package/esm/maths/random/rndHelpers.js.map +0 -1
- package/esm/maths/random/rndMonom.js +0 -46
- package/esm/maths/random/rndMonom.js.map +0 -1
- package/esm/maths/random/rndPolynom.js +0 -63
- package/esm/maths/random/rndPolynom.js.map +0 -1
- package/esm/maths/random/rndTypes.js.map +0 -1
- package/src/maths/algebra/index.ts +0 -7
- package/src/maths/coefficients/index.ts +0 -2
- package/src/maths/geometry/index.ts +0 -5
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* This class works for 2d line in a plane.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import {Fraction} from "../coefficients";
|
|
6
5
|
import {Vector} from "./vector";
|
|
7
6
|
import {Point} from "./point";
|
|
8
|
-
import {Equation, Polynom} from "../algebra";
|
|
9
7
|
import {Numeric} from "../numeric";
|
|
8
|
+
import {Fraction} from "../coefficients/fraction";
|
|
9
|
+
import {Equation} from "../algebra/equation";
|
|
10
|
+
import {Polynom} from "../algebra/polynom";
|
|
10
11
|
|
|
11
|
-
enum LinePropriety {
|
|
12
|
+
export enum LinePropriety {
|
|
12
13
|
None,
|
|
13
14
|
Parallel='parallel',
|
|
14
15
|
Perpendicular = 'perpendicular',
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Vector module contains everything necessary to handle 2d or 3d vectors.
|
|
3
3
|
* @module Vector
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import {Line} from "./line";
|
|
6
|
+
import {Vector} from "./vector";
|
|
7
|
+
import {Fraction} from "../coefficients/fraction";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Helper class - a way to identify an object {x: number, y: number}
|
|
@@ -68,8 +70,6 @@ export class Point {
|
|
|
68
70
|
// ------------------------------------------
|
|
69
71
|
// Creation / parsing functions
|
|
70
72
|
// ------------------------------------------
|
|
71
|
-
|
|
72
|
-
|
|
73
73
|
parse = (...values: unknown[]): Point => {
|
|
74
74
|
// Initialize the value.
|
|
75
75
|
this.zero();
|
|
@@ -171,4 +171,27 @@ export class Point {
|
|
|
171
171
|
}
|
|
172
172
|
};
|
|
173
173
|
|
|
174
|
+
distanceTo = (item:Point|Line): { value: number, fraction: Fraction, tex: string } => {
|
|
175
|
+
let value = 0, fraction = new Fraction(), tex = ''
|
|
176
|
+
|
|
177
|
+
if(item instanceof Line){
|
|
178
|
+
return item.distanceTo(this)
|
|
179
|
+
}else if(item instanceof Point){
|
|
180
|
+
let V = new Vector(this, item)
|
|
181
|
+
|
|
182
|
+
value = V.norm
|
|
183
|
+
fraction = V.normSquare.sqrt()
|
|
184
|
+
tex = V.normSquare.isSquare()?fraction.tex:`\\sqrt{\\dfrac{ ${V.normSquare.numerator} }{ ${V.normSquare.denominator} }}`
|
|
185
|
+
}
|
|
186
|
+
return { value, fraction, tex }
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
get key(): string {
|
|
190
|
+
return `${this.x.display};${this.y.display}`
|
|
191
|
+
}
|
|
192
|
+
isInListOfPoints = (list: Point[]): boolean => {
|
|
193
|
+
const keyList = list.map(x=>x.key)
|
|
194
|
+
|
|
195
|
+
return keyList.includes(this.key)
|
|
196
|
+
}
|
|
174
197
|
}
|
package/src/maths/numeric.ts
CHANGED
|
@@ -89,4 +89,19 @@ export class Numeric{
|
|
|
89
89
|
return Math.abs(a * b / Numeric.gcd(a, b));
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
+
|
|
93
|
+
static pythagoricianTripletsWithTarget(target: number, targetIsSquare?:boolean): number[][] {
|
|
94
|
+
// méthode inverse, à partir du triplet.
|
|
95
|
+
const triplets = [],
|
|
96
|
+
targetValue = targetIsSquare===true?+target:target**2
|
|
97
|
+
for(let u = 0; u <= target; u++){
|
|
98
|
+
for(let v = 0; v <=target; v++){
|
|
99
|
+
if(u**2+v**2===targetValue){
|
|
100
|
+
triplets.push([u, v, target])
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return triplets
|
|
106
|
+
}
|
|
92
107
|
}
|
|
@@ -2,9 +2,10 @@ import {rndPolynom} from "./rndPolynom";
|
|
|
2
2
|
import {rndMonom} from "./rndMonom";
|
|
3
3
|
import {rndHelpers} from "./rndHelpers";
|
|
4
4
|
import {randomCoefficientConfig, randomMonomConfig, randomPolynomConfig} from "./rndTypes";
|
|
5
|
-
import {Monom, Polynom} from "../algebra";
|
|
6
|
-
import {Fraction} from "../coefficients";
|
|
7
5
|
import {rndFraction} from "./rndFraction";
|
|
6
|
+
import {Polynom} from "../algebra/polynom";
|
|
7
|
+
import {Monom} from "../algebra/monom";
|
|
8
|
+
import {Fraction} from "../coefficients/fraction";
|
|
8
9
|
|
|
9
10
|
export * from "./rndTypes"
|
|
10
11
|
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {randomCore} from "./randomCore";
|
|
2
2
|
import {randomCoefficientConfig, randomMonomConfig, randomPolynomConfig} from "./rndTypes";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import {Random} from "./random";
|
|
4
|
+
import {Fraction} from "../coefficients/fraction";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a random monom based on a based configuration
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {randomCore} from "./randomCore";
|
|
2
2
|
import {randomMonomConfig} from "./rndTypes";
|
|
3
|
-
import {Random} from "./
|
|
4
|
-
import {Monom} from "../algebra";
|
|
3
|
+
import {Random} from "./random";
|
|
4
|
+
import {Monom} from "../algebra/monom";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a random monom based on a based configuration
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {randomCore} from "./randomCore";
|
|
2
2
|
import {randomPolynomConfig} from "./rndTypes";
|
|
3
3
|
import {rndMonom} from "./rndMonom";
|
|
4
|
-
import {Random} from "./
|
|
5
|
-
import {Polynom} from "../algebra";
|
|
6
|
-
import {Monom} from "../algebra";
|
|
4
|
+
import {Random} from "./random";
|
|
5
|
+
import {Polynom} from "../algebra/polynom";
|
|
6
|
+
import {Monom} from "../algebra/monom";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Random polynoms
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
2
|
import {Monom} from "../../src/maths/algebra";
|
|
3
|
-
import {Random} from "../../src/maths/random";
|
|
3
|
+
import {Random} from "../../src/maths/randomization/random";
|
|
4
4
|
import {describe} from "mocha";
|
|
5
5
|
import {Fraction} from "../../src/maths/coefficients";
|
|
6
6
|
import {Shutingyard} from "../../src/maths/shutingyard";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
|
-
import {
|
|
3
|
-
import {Monom, Polynom} from "../../src/maths/algebra";
|
|
4
|
-
import {Random} from "../../src/maths/random";
|
|
2
|
+
import {Random} from "../../src/maths/randomization/random";
|
|
5
3
|
import {describe} from "mocha";
|
|
6
|
-
import {
|
|
4
|
+
import {Polynom} from "../../src/maths/algebra/polynom";
|
|
5
|
+
import {Fraction} from "../../src/maths/coefficients/fraction";
|
|
7
6
|
|
|
8
7
|
describe('Polynom tests', () => {
|
|
9
8
|
it('Parse polynom', () => {
|
|
@@ -12,7 +11,7 @@ describe('Polynom tests', () => {
|
|
|
12
11
|
expect(options.tex).to.be.equal('2x^{4}+10x^{3}+6x^{2}-18x');
|
|
13
12
|
});
|
|
14
13
|
|
|
15
|
-
it('Parse polynom with coefficient as fraction', ()=>{
|
|
14
|
+
it('Parse polynom with coefficient as fraction', () => {
|
|
16
15
|
const P = new Polynom('-3/5x-2')
|
|
17
16
|
|
|
18
17
|
console.log(P.tex)
|
|
@@ -68,16 +67,16 @@ describe('Polynom tests', () => {
|
|
|
68
67
|
expect(euclidian.reminder.tex).to.be.equal('12')
|
|
69
68
|
});
|
|
70
69
|
|
|
71
|
-
it('should factorize the polynom', ()=> {
|
|
70
|
+
it('should factorize the polynom', () => {
|
|
72
71
|
let P = new Polynom('x^2-5x+6')
|
|
73
72
|
|
|
74
73
|
P.factorize()
|
|
75
|
-
expect(P.factors.map(x=>x.tex)).to.have.all.members(['x-2', 'x-3'])
|
|
74
|
+
expect(P.factors.map(x => x.tex)).to.have.all.members(['x-2', 'x-3'])
|
|
76
75
|
})
|
|
77
76
|
})
|
|
78
77
|
|
|
79
|
-
describe('Polynom parsing with rational power', ()=>{
|
|
80
|
-
it('should parse with rational powers', ()=> {
|
|
78
|
+
describe('Polynom parsing with rational power', () => {
|
|
79
|
+
it('should parse with rational powers', () => {
|
|
81
80
|
const P = new Polynom('3x^(2/3)-5x+5/3');
|
|
82
81
|
|
|
83
82
|
expect(P.tex).to.be.equal('3x^{\\tfrac{ 2 }{ 3 }}-5x+\\dfrac{ 5 }{ 3 }')
|
|
@@ -25,4 +25,37 @@ describe('Circle', function () {
|
|
|
25
25
|
expect(IPS[1].x.value).to.be.equal(6)
|
|
26
26
|
expect(IPS[1].y.value).to.be.equal(10)
|
|
27
27
|
});
|
|
28
|
+
|
|
29
|
+
it('should calculate tangents', function(){
|
|
30
|
+
|
|
31
|
+
// Through one point on the circle
|
|
32
|
+
const C = new Circle(
|
|
33
|
+
new Point(-2, 3),
|
|
34
|
+
25,
|
|
35
|
+
true
|
|
36
|
+
), P = new Point(-5, 7);
|
|
37
|
+
|
|
38
|
+
expect(C.tangents(P).map(x=>x.tex.canonical)).to.have.all.members(['3x-4y+43=0'])
|
|
39
|
+
|
|
40
|
+
// With a slope
|
|
41
|
+
const D = new Circle('x^2+y^2+10x=2y-6'),
|
|
42
|
+
slope = new Fraction(-2, 1)
|
|
43
|
+
|
|
44
|
+
expect(D.tangents(slope).map(x=>x.tex.canonical)).to.have.all.members(['2x+y-1=0', '2x+y+19=0'])
|
|
45
|
+
|
|
46
|
+
const E = new Circle('(x-2)^2+(y-1)^2=5'),
|
|
47
|
+
P2 = new Point(6, -2)
|
|
48
|
+
|
|
49
|
+
expect(E.tangents(P2).map(x=>x.tex.canonical)).to.have.all.members(['2x+y-10=0','2x+11y+10=0'])
|
|
50
|
+
|
|
51
|
+
let P3 = new Point(2, 2)
|
|
52
|
+
expect(E.tangents(P3)).to.be.empty
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('should get a list of point on the circle', function () {
|
|
56
|
+
const C = new Circle('(x-3)^2+(y+4)^2=16'),
|
|
57
|
+
pts = C.getPointsOnCircle()
|
|
58
|
+
|
|
59
|
+
expect(pts.map(x=>x.x.display + ',' + x.y.display)).to.have.all.members([ '3,0', '3,-8', '7,-4', '-1,-4' ])
|
|
60
|
+
});
|
|
28
61
|
});
|
package/tsconfig.json
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"outDir": "./esm/",
|
|
18
18
|
"noImplicitAny": true,
|
|
19
19
|
"module": "commonjs",
|
|
20
|
-
"target": "
|
|
20
|
+
"target": "es2021",
|
|
21
21
|
"allowJs": true,
|
|
22
22
|
"sourceMap": true,
|
|
23
23
|
"moduleResolution": "node",
|
|
24
24
|
"declaration": true,
|
|
25
|
-
"removeComments":
|
|
25
|
+
"removeComments": false
|
|
26
26
|
},
|
|
27
27
|
"include": [
|
|
28
28
|
"./src/**/*"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
mode: 'production',
|
|
5
|
+
entry: './src/main.ts',
|
|
6
|
+
devtool: 'source-map',
|
|
7
|
+
module: {
|
|
8
|
+
rules: [
|
|
9
|
+
{
|
|
10
|
+
test: /\.tsx?$/,
|
|
11
|
+
use: 'ts-loader',
|
|
12
|
+
exclude: /node_module/,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
resolve: {
|
|
17
|
+
extensions: ['.tsx','.ts', '.js'],
|
|
18
|
+
},
|
|
19
|
+
output: {
|
|
20
|
+
filename: 'pi.min.js',
|
|
21
|
+
path: path.resolve(__dirname, 'dist'),
|
|
22
|
+
},
|
|
23
|
+
optimization: {
|
|
24
|
+
minimize: true
|
|
25
|
+
}
|
|
26
|
+
};
|