pimath 0.0.21 → 0.0.25
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/dev/demo.css +3 -0
- package/dev/index.html +216 -53
- package/dev/pi.js +374 -132
- package/dev/pi.js.map +1 -1
- package/dist/pi.js +1 -1
- package/dist/pi.js.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/algebra.Equation.html +11 -13
- package/docs/classes/algebra.LinearSystem.html +1 -1
- package/docs/classes/algebra.Logicalset.html +3 -3
- package/docs/classes/algebra.Monom.html +42 -42
- package/docs/classes/algebra.Polynom.html +12 -25
- package/docs/classes/algebra.Rational.html +3 -3
- package/docs/classes/coefficients.Fraction.html +10 -6
- package/docs/classes/coefficients.Nthroot.html +3 -1
- package/docs/classes/geometry.Circle.html +3 -1
- package/docs/classes/geometry.Line.html +3 -1
- package/docs/classes/geometry.Point.html +1 -1
- package/docs/classes/geometry.Triangle.html +6 -6
- package/docs/classes/geometry.Vector.html +1 -1
- package/docs/classes/numeric.Numeric.html +5 -5
- package/docs/classes/shutingyard.Shutingyard.html +5 -5
- package/docs/index.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/numeric.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/docs/modules.html +1 -1
- package/esm/maths/algebra/equation.d.ts +11 -5
- package/esm/maths/algebra/equation.js +159 -52
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +3 -4
- package/esm/maths/algebra/linearSystem.js +2 -5
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.d.ts +2 -2
- package/esm/maths/algebra/logicalset.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +3 -2
- package/esm/maths/algebra/monom.js +22 -1
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +6 -6
- package/esm/maths/algebra/polynom.js +3 -3
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +2 -2
- package/esm/maths/coefficients/fraction.js +1 -1
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/nthroot.d.ts +1 -1
- package/esm/maths/coefficients/nthroot.js +4 -1
- package/esm/maths/coefficients/nthroot.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +12 -3
- package/esm/maths/geometry/circle.js +125 -39
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +4 -4
- package/esm/maths/geometry/line.js +17 -7
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +3 -4
- package/esm/maths/geometry/point.js +18 -15
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +0 -1
- package/esm/maths/geometry/triangle.js +3 -4
- package/esm/maths/geometry/triangle.js.map +1 -1
- package/esm/maths/geometry/vector.js +2 -1
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/random/index.js +18 -6
- package/esm/maths/random/index.js.map +1 -1
- package/esm/maths/random/rndFraction.js +4 -3
- package/esm/maths/random/rndFraction.js.map +1 -1
- package/esm/maths/random/rndMonom.d.ts +1 -1
- package/esm/maths/random/rndMonom.js +12 -7
- package/esm/maths/random/rndMonom.js.map +1 -1
- package/esm/maths/random/rndPolynom.js +8 -2
- package/esm/maths/random/rndPolynom.js.map +1 -1
- package/esm/maths/random/rndTypes.d.ts +3 -1
- package/package.json +3 -5
- package/src/maths/algebra/equation.ts +183 -73
- package/src/maths/algebra/linearSystem.ts +262 -265
- package/src/maths/algebra/logicalset.ts +1 -1
- package/src/maths/algebra/monom.ts +24 -18
- package/src/maths/algebra/polynom.ts +9 -9
- package/src/maths/coefficients/fraction.ts +11 -7
- package/src/maths/coefficients/nthroot.ts +8 -1
- package/src/maths/geometry/circle.ts +160 -45
- package/src/maths/geometry/line.ts +30 -11
- package/src/maths/geometry/point.ts +25 -18
- package/src/maths/geometry/triangle.ts +3 -5
- package/src/maths/geometry/vector.ts +4 -3
- package/src/maths/random/index.ts +24 -6
- package/src/maths/random/rndFraction.ts +4 -3
- package/src/maths/random/rndMonom.ts +39 -35
- package/src/maths/random/rndPolynom.ts +13 -3
- package/src/maths/random/rndTypes.ts +4 -2
- package/tests/algebra/monom.test.ts +18 -4
- package/tests/algebra/polynom.test.ts +10 -4
- package/tests/geometry/circle.test.ts +28 -0
- package/tsconfig.json +4 -1
- package/typedoc.katex.js +11 -0
- package/docs/classes/algebra.Algebra.Equation.html +0 -26
- package/docs/classes/algebra.Algebra.LinearSystem.html +0 -1
- package/docs/classes/algebra.Algebra.LogicalSet.html +0 -3
- package/docs/classes/algebra.Algebra.Monom.html +0 -111
- package/docs/classes/algebra.Algebra.Polynom.html +0 -36
- package/docs/classes/algebra.Algebra.Rational.html +0 -2
- package/docs/classes/geometry.Geometry.Circle.html +0 -1
- package/docs/classes/geometry.Geometry.Line.html +0 -1
- package/docs/classes/geometry.Geometry.Point.html +0 -1
- package/docs/classes/geometry.Geometry.Triangle.html +0 -9
- package/docs/classes/geometry.Geometry.Vector.html +0 -1
- package/docs/modules/algebra.Algebra.html +0 -1
- package/docs/modules/geometry.Geometry.html +0 -1
- package/src/maths/algebra/monom_bck.backup +0 -746
|
@@ -56,8 +56,6 @@ export class Triangle {
|
|
|
56
56
|
return this;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
get isTriangle():boolean {return true;}
|
|
60
|
-
|
|
61
59
|
// ------------------------------------------
|
|
62
60
|
// Getter and setters
|
|
63
61
|
// ------------------------------------------
|
|
@@ -158,7 +156,7 @@ export class Triangle {
|
|
|
158
156
|
// - Three lines as text.
|
|
159
157
|
if(values.filter((x:any) => typeof x === 'string').length===3) {
|
|
160
158
|
return this.parse( ...values.map((x:string) => new Line(x)) )
|
|
161
|
-
}else if(values.filter((x:any) => x
|
|
159
|
+
}else if(values.filter((x:any) => x instanceof Line).length===3) {
|
|
162
160
|
// We have three lines
|
|
163
161
|
this._lines = {
|
|
164
162
|
'AB': values[0],
|
|
@@ -187,7 +185,7 @@ export class Triangle {
|
|
|
187
185
|
}
|
|
188
186
|
}else {
|
|
189
187
|
// At least, one of the value is not a point.
|
|
190
|
-
if (values.filter((x: any) => x
|
|
188
|
+
if (values.filter((x: any) => (x instanceof Point)).length < 3) {
|
|
191
189
|
return this.parse(
|
|
192
190
|
new Point(values[0]),
|
|
193
191
|
new Point(values[1]),
|
|
@@ -207,7 +205,7 @@ export class Triangle {
|
|
|
207
205
|
};
|
|
208
206
|
}
|
|
209
207
|
} else if (values.length === 1) {
|
|
210
|
-
if (values[0]
|
|
208
|
+
if (values[0] instanceof Triangle) {
|
|
211
209
|
return values[0].clone();
|
|
212
210
|
}
|
|
213
211
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import {Fraction} from "../coefficients/fraction";
|
|
6
6
|
import {Numeric} from "../numeric";
|
|
7
|
+
import {Point} from "./point";
|
|
7
8
|
|
|
8
9
|
export class Vector {
|
|
9
10
|
private _x: Fraction; // 1st component
|
|
@@ -73,7 +74,7 @@ export class Vector {
|
|
|
73
74
|
|
|
74
75
|
if (values.length >= 2) {
|
|
75
76
|
// Two points are given - skip the third value.
|
|
76
|
-
if (values[0]
|
|
77
|
+
if (values[0] instanceof Point && values[1] instanceof Point) {
|
|
77
78
|
this._x = values[1].x.clone().subtract(values[0].x)
|
|
78
79
|
this._y = values[1].y.clone().subtract(values[0].y)
|
|
79
80
|
return this;
|
|
@@ -159,7 +160,7 @@ export class Vector {
|
|
|
159
160
|
|
|
160
161
|
static scalarProduct = (v1: Vector, v2: Vector): number => {
|
|
161
162
|
// TODO: Transform to fraction with nthroot.
|
|
162
|
-
return
|
|
163
|
+
return v1.x.value * v2.x.value + v1.y.value * v2.y.value;
|
|
163
164
|
};
|
|
164
165
|
|
|
165
166
|
normal = (): Vector => {
|
|
@@ -180,7 +181,7 @@ export class Vector {
|
|
|
180
181
|
return this;
|
|
181
182
|
}
|
|
182
183
|
|
|
183
|
-
divideByScalar = (k:any): Vector => {
|
|
184
|
+
divideByScalar = (k: any): Vector => {
|
|
184
185
|
return this.multiplyByScalar(new Fraction(k).invert());
|
|
185
186
|
}
|
|
186
187
|
// ------------------------------------------
|
|
@@ -7,6 +7,7 @@ import {Fraction} from "../coefficients";
|
|
|
7
7
|
import {rndFraction} from "./rndFraction";
|
|
8
8
|
|
|
9
9
|
export * from "./rndTypes"
|
|
10
|
+
|
|
10
11
|
export namespace Random {
|
|
11
12
|
export function polynom(config?: randomPolynomConfig): Polynom {
|
|
12
13
|
return (new rndPolynom(config)).generate()
|
|
@@ -20,10 +21,27 @@ export namespace Random {
|
|
|
20
21
|
return (new rndFraction(config)).generate()
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export function number(from:number, to:number):number {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export function
|
|
28
|
-
|
|
24
|
+
export function number(from: number, to: number): number {
|
|
25
|
+
return rndHelpers.randomInt(from, to)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function numberSym(max: number, allowZero?: boolean): number {
|
|
29
|
+
return rndHelpers.randomIntSym(max, allowZero)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function bool(percent?: number): boolean {
|
|
33
|
+
return rndHelpers.randomBool(percent)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function array(arr: any[], number?: number): any[] {
|
|
37
|
+
return rndHelpers.randomArray(arr, number)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function item(arr: any[]): any {
|
|
41
|
+
return rndHelpers.randomItem(arr)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function shuffle(arr: any[]): any {
|
|
45
|
+
rndHelpers.shuffleArray(arr)
|
|
46
|
+
}
|
|
29
47
|
}
|
|
@@ -15,6 +15,7 @@ export class rndFraction extends randomCore {
|
|
|
15
15
|
|
|
16
16
|
this._defaultConfig = {
|
|
17
17
|
negative: true,
|
|
18
|
+
max: 10,
|
|
18
19
|
reduced: true,
|
|
19
20
|
zero: true,
|
|
20
21
|
natural: false
|
|
@@ -27,14 +28,14 @@ export class rndFraction extends randomCore {
|
|
|
27
28
|
let Q = new Fraction()
|
|
28
29
|
|
|
29
30
|
if(this._config.negative){
|
|
30
|
-
Q.numerator = Random.numberSym(
|
|
31
|
+
Q.numerator = Random.numberSym(this._config.max, this._config.zero)
|
|
31
32
|
}else {
|
|
32
|
-
Q.numerator = Random.number(this._config.zero ? 0 : 1,
|
|
33
|
+
Q.numerator = Random.number(this._config.zero ? 0 : 1, this._config.max)
|
|
33
34
|
}
|
|
34
35
|
if(this._config.natural){
|
|
35
36
|
Q.denominator = 1
|
|
36
37
|
}else {
|
|
37
|
-
Q.denominator = Random.number(1,
|
|
38
|
+
Q.denominator = Random.number(1, this._config.max)
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
return this._config.reduced?Q.reduce():Q
|
|
@@ -1,53 +1,57 @@
|
|
|
1
1
|
import {randomCore} from "./randomCore";
|
|
2
|
-
import {randomMonomConfig
|
|
2
|
+
import {randomMonomConfig} from "./rndTypes";
|
|
3
3
|
import {Random} from "./index";
|
|
4
|
-
import {Monom} from "../algebra
|
|
4
|
+
import {Monom} from "../algebra";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a random monom based on a based configuration
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
this._config = this.mergeConfig(userConfig, this._defaultConfig)
|
|
9
|
+
export class rndMonom extends randomCore {
|
|
10
|
+
declare protected _config: randomMonomConfig
|
|
11
|
+
declare protected _defaultConfig: randomMonomConfig
|
|
12
|
+
|
|
13
|
+
constructor(userConfig?: randomMonomConfig) {
|
|
14
|
+
super();
|
|
15
|
+
|
|
16
|
+
this._defaultConfig = {
|
|
17
|
+
letters: 'x',
|
|
18
|
+
degree: 2,
|
|
19
|
+
fraction: true,
|
|
20
|
+
zero: false
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
this._config = this.mergeConfig(userConfig, this._defaultConfig)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
generate = (): Monom => {
|
|
27
|
+
// Create a monom instance
|
|
28
|
+
let M = new Monom()
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
// Generate the coefficient
|
|
31
|
+
if (typeof this._config.fraction === "boolean") {
|
|
31
32
|
M.coefficient = Random.fraction({
|
|
32
33
|
zero: this._config.zero,
|
|
33
34
|
reduced: true,
|
|
34
35
|
natural: !this._config.fraction
|
|
35
36
|
})
|
|
37
|
+
} else {
|
|
38
|
+
M.coefficient = Random.fraction(this._config.fraction)
|
|
39
|
+
}
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
for (let i = 0; i < this._config.degree; i++) {
|
|
44
|
-
const L = Random.item(this._config.letters.split(""))
|
|
45
|
-
M.setLetter(L, M.degree(L).clone().add(1))
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
M.setLetter(this._config.letters, this._config.degree)
|
|
41
|
+
// Calculate the degree of the monom
|
|
42
|
+
if (this._config.letters.length > 1) {
|
|
43
|
+
// Initialise each items...
|
|
44
|
+
for (let L of this._config.letters.split('')) {
|
|
45
|
+
M.setLetter(L, 0);
|
|
49
46
|
}
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
for (let i = 0; i < this._config.degree; i++) {
|
|
48
|
+
const L = Random.item(this._config.letters.split(""))
|
|
49
|
+
M.setLetter(L, M.degree(L).clone().add(1))
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
M.setLetter(this._config.letters, this._config.degree)
|
|
52
53
|
}
|
|
54
|
+
|
|
55
|
+
return M
|
|
53
56
|
}
|
|
57
|
+
}
|
|
@@ -24,7 +24,8 @@ export class rndPolynom extends randomCore {
|
|
|
24
24
|
unit: false,
|
|
25
25
|
factorable: false,
|
|
26
26
|
allowNullMonom: true,
|
|
27
|
-
numberOfMonoms: 0
|
|
27
|
+
numberOfMonoms: 0,
|
|
28
|
+
positive: true
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
// Merge config with initialiser
|
|
@@ -39,6 +40,7 @@ export class rndPolynom extends randomCore {
|
|
|
39
40
|
// Create the polynom
|
|
40
41
|
let P = new Polynom().empty(),
|
|
41
42
|
M: Monom
|
|
43
|
+
|
|
42
44
|
for (let i = this._config.degree; i >= 0; i--) {
|
|
43
45
|
// Create monom of corresponding degree.
|
|
44
46
|
M = new rndMonom({
|
|
@@ -57,9 +59,17 @@ export class rndPolynom extends randomCore {
|
|
|
57
59
|
P.add(M)
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
//
|
|
62
|
+
// Make sure the first monom is positive.
|
|
63
|
+
if(this._config.positive && P.monomByDegree().coefficient.isNegative()){
|
|
64
|
+
P.monomByDegree().coefficient.opposed()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// If the number of monoms is greater than the allowed value, remove some of them... except the first one !
|
|
61
68
|
if (this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < P.length) {
|
|
62
|
-
|
|
69
|
+
// Get the greatest degree monom
|
|
70
|
+
let M = P.monomByDegree().clone()
|
|
71
|
+
P.monoms = Random.array(P.monoms.slice(1), this._config.numberOfMonoms-1)
|
|
72
|
+
P.add(M).reorder().reduce()
|
|
63
73
|
}
|
|
64
74
|
return P
|
|
65
75
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type randomCoefficientConfig = {
|
|
2
2
|
negative?: boolean,
|
|
3
|
+
max?: number,
|
|
3
4
|
reduced?: boolean,
|
|
4
5
|
zero?:boolean,
|
|
5
6
|
natural?:boolean
|
|
@@ -8,7 +9,7 @@ export type randomCoefficientConfig = {
|
|
|
8
9
|
export type randomMonomConfig = {
|
|
9
10
|
letters?: string,
|
|
10
11
|
degree?: number,
|
|
11
|
-
fraction?: boolean,
|
|
12
|
+
fraction?: boolean|randomCoefficientConfig,
|
|
12
13
|
zero?: boolean
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -16,5 +17,6 @@ export type randomPolynomConfig = randomMonomConfig & {
|
|
|
16
17
|
unit?: boolean,
|
|
17
18
|
factorable?: boolean,
|
|
18
19
|
allowNullMonom?: boolean,
|
|
19
|
-
numberOfMonoms?: number
|
|
20
|
+
numberOfMonoms?: number,
|
|
21
|
+
positive?: boolean
|
|
20
22
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
2
|
import {Monom} from "../../src/maths/algebra";
|
|
3
3
|
import {Random} from "../../src/maths/random";
|
|
4
|
-
import
|
|
4
|
+
import {describe} from "mocha";
|
|
5
|
+
import {Fraction} from "../../src/maths/coefficients";
|
|
5
6
|
|
|
6
|
-
describe('Monom tests', ()=> {
|
|
7
|
-
it('parsing', ()=>{
|
|
7
|
+
describe('Monom tests', () => {
|
|
8
|
+
it('parsing', () => {
|
|
8
9
|
const M0a = new Monom('3');
|
|
9
10
|
expect(M0a.tex).to.be.equal('3')
|
|
10
11
|
|
|
@@ -30,7 +31,7 @@ describe('Monom tests', ()=> {
|
|
|
30
31
|
expect(M5.tex).to.be.equal('-24x^{7/3}y^{-5}')
|
|
31
32
|
})
|
|
32
33
|
|
|
33
|
-
it('basic operations', ()=>{
|
|
34
|
+
it('basic operations', () => {
|
|
34
35
|
const M1 = new Monom('3x'),
|
|
35
36
|
M2 = new Monom('2x')
|
|
36
37
|
|
|
@@ -64,3 +65,16 @@ describe('Monom tests', ()=> {
|
|
|
64
65
|
expect(M.degree().value).to.be.greaterThan(0)
|
|
65
66
|
});
|
|
66
67
|
})
|
|
68
|
+
|
|
69
|
+
describe('Monom as numerical expression', () => {
|
|
70
|
+
it('should create a numerical expression', () => {
|
|
71
|
+
let M = new Monom()
|
|
72
|
+
|
|
73
|
+
M.coefficient = new Fraction(3, 7)
|
|
74
|
+
M.setLetter('3', new Fraction(0.5).reduce())
|
|
75
|
+
|
|
76
|
+
console.log(M.tex)
|
|
77
|
+
// TODO: Problem while displaying numerical expression
|
|
78
|
+
console.log(M.display)
|
|
79
|
+
})
|
|
80
|
+
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {expect} from 'chai';
|
|
2
2
|
import {Fraction} from "../../src/maths/coefficients";
|
|
3
|
-
import {Polynom} from "../../src/maths/algebra";
|
|
3
|
+
import {Monom, Polynom} from "../../src/maths/algebra";
|
|
4
4
|
import {Random} from "../../src/maths/random";
|
|
5
|
+
import {describe} from "mocha";
|
|
5
6
|
|
|
6
7
|
describe('Polynom tests', () => {
|
|
7
8
|
it('Parse polynom', () => {
|
|
@@ -38,10 +39,15 @@ describe('Polynom tests', () => {
|
|
|
38
39
|
it('Random Polynom of degree 5', function () {
|
|
39
40
|
let P = Random.polynom({
|
|
40
41
|
degree: 6,
|
|
41
|
-
numberOfMonoms: 3
|
|
42
|
+
numberOfMonoms: 3,
|
|
43
|
+
positive: true,
|
|
44
|
+
fraction: {
|
|
45
|
+
max: 3
|
|
46
|
+
}
|
|
42
47
|
})
|
|
43
48
|
|
|
49
|
+
console.log(P.tex)
|
|
44
50
|
expect(P.length).to.be.equal(3)
|
|
45
|
-
expect(P.degree().value).to.be.
|
|
51
|
+
expect(P.degree().value).to.be.equal(6)
|
|
46
52
|
});
|
|
47
|
-
})
|
|
53
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {describe} from "mocha";
|
|
2
|
+
import {Circle, Line, Point} from "../../src/maths/geometry";
|
|
3
|
+
import {Fraction} from "../../src/maths/coefficients";
|
|
4
|
+
import {expect} from "chai";
|
|
5
|
+
|
|
6
|
+
describe('Circle', function () {
|
|
7
|
+
it('should calculate the intersection of a circle and a line', function () {
|
|
8
|
+
let C = new Circle(
|
|
9
|
+
new Point(8, 6),
|
|
10
|
+
20,
|
|
11
|
+
true
|
|
12
|
+
),
|
|
13
|
+
LT = new Line('2x+y-32=0'),
|
|
14
|
+
LS = new Line('3x-y-8=0'),
|
|
15
|
+
IPT = C.lineIntersection(LT),
|
|
16
|
+
IPS = C.lineIntersection(LS)
|
|
17
|
+
|
|
18
|
+
expect(IPT).to.be.length(1)
|
|
19
|
+
expect(IPT[0].x.value).to.be.equal(12)
|
|
20
|
+
expect(IPT[0].y.value).to.be.equal(8)
|
|
21
|
+
|
|
22
|
+
expect(IPS).to.be.length(2)
|
|
23
|
+
expect(IPS[0].x.value).to.be.equal(4)
|
|
24
|
+
expect(IPS[0].y.value).to.be.equal(4)
|
|
25
|
+
expect(IPS[1].x.value).to.be.equal(6)
|
|
26
|
+
expect(IPS[1].y.value).to.be.equal(10)
|
|
27
|
+
});
|
|
28
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
"src/maths/numeric.ts",
|
|
9
9
|
"src/maths/shutingyard.ts"
|
|
10
10
|
],
|
|
11
|
+
"plugin": [
|
|
12
|
+
"./typedoc.katex.js"
|
|
13
|
+
],
|
|
11
14
|
"out": "docs"
|
|
12
15
|
},
|
|
13
16
|
"compilerOptions": {
|
|
@@ -16,7 +19,7 @@
|
|
|
16
19
|
"module": "commonjs",
|
|
17
20
|
"target": "esnext",
|
|
18
21
|
"allowJs": true,
|
|
19
|
-
// "jsx": "react",
|
|
22
|
+
// "jsx": "react-jsx",
|
|
20
23
|
"sourceMap": true,
|
|
21
24
|
"moduleResolution": "node",
|
|
22
25
|
"declaration": true,
|
package/typedoc.katex.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { JSX } = require("typedoc");
|
|
2
|
+
|
|
3
|
+
exports.load = function (app) {
|
|
4
|
+
app.renderer.hooks.on("head.end", () => {
|
|
5
|
+
return JSX.createElement(JSX.Fragment, null,
|
|
6
|
+
JSX.createElement("link", { rel: "stylesheet", href: "https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.css", integrity: "sha384-R4558gYOUz8mP9YWpZJjofhk+zx0AS11p36HnD2ZKj/6JR5z27gSSULCNHIRReVs", crossorigin: "anonymous" },
|
|
7
|
+
JSX.createElement("script", { defer: true, src: "https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/katex.min.js", integrity: "sha384-z1fJDqw8ZApjGO3/unPWUPsIymfsJmyrDVWC8Tv/a1HeOtGmkwNd/7xUS0Xcnvsx", crossorigin: "anonymous" }),
|
|
8
|
+
JSX.createElement("script", { defer: true, src: "https://cdn.jsdelivr.net/npm/katex@0.15.1/dist/contrib/auto-render.min.js", integrity: "sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR", crossorigin: "anonymous", onload: "renderMathInElement(document.body);" })),
|
|
9
|
+
"}); }");
|
|
10
|
+
});
|
|
11
|
+
}
|