pimath 0.1.40 → 0.2.1
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/pimath.js +3106 -2873
- package/dist/pimath.js.map +1 -1
- package/package.json +13 -11
- package/src/algebra/equation.ts +113 -111
- package/src/algebra/equationSolver.ts +69 -120
- package/src/algebra/factor.ts +6 -7
- package/src/algebra/linearSystem.ts +97 -46
- package/src/algebra/logicalset.ts +51 -52
- package/src/algebra/monom.ts +23 -61
- package/src/algebra/operations.ts +0 -1
- package/src/algebra/polyFactor.ts +5 -5
- package/src/algebra/polynom.ts +69 -216
- package/src/analyze/index.ts +4 -0
- package/src/analyze/solution.ts +92 -29
- package/src/analyze/tableOfSigns.ts +1 -1
- package/src/coefficients/fraction.ts +189 -149
- package/src/coefficients/index.ts +1 -1
- package/src/coefficients/root.ts +66 -19
- package/src/geometry/TupleN.ts +128 -0
- package/src/geometry/circle.ts +308 -238
- package/src/geometry/geomMath.ts +4 -3
- package/src/geometry/index.ts +1 -0
- package/src/geometry/line.ts +221 -245
- package/src/geometry/line3.ts +78 -73
- package/src/geometry/plane3.ts +64 -55
- package/src/geometry/point.ts +57 -19
- package/src/geometry/triangle.ts +376 -248
- package/src/geometry/vector.ts +113 -229
- package/src/index.ts +13 -12
- package/src/numeric.ts +6 -9
- package/src/pimath.interface.ts +30 -28
- package/src/randomization/algebra/rndPolynom.ts +29 -15
- package/src/randomization/coefficient/rndFraction.ts +3 -3
- package/src/randomization/geometry/rndLine.ts +8 -10
- package/src/randomization/random.ts +11 -13
- package/src/randomization/rndTypes.ts +16 -12
- package/types/algebra/equation.d.ts +18 -17
- package/types/algebra/equation.d.ts.map +1 -1
- package/types/algebra/equationSolver.d.ts +5 -4
- package/types/algebra/equationSolver.d.ts.map +1 -1
- package/types/algebra/factor.d.ts +1 -1
- package/types/algebra/factor.d.ts.map +1 -1
- package/types/algebra/linearSystem.d.ts +23 -6
- package/types/algebra/linearSystem.d.ts.map +1 -1
- package/types/algebra/logicalset.d.ts +1 -1
- package/types/algebra/logicalset.d.ts.map +1 -1
- package/types/algebra/monom.d.ts +1 -6
- package/types/algebra/monom.d.ts.map +1 -1
- package/types/algebra/operations.d.ts.map +1 -1
- package/types/algebra/polyFactor.d.ts +4 -4
- package/types/algebra/polyFactor.d.ts.map +1 -1
- package/types/algebra/polynom.d.ts +10 -7
- package/types/algebra/polynom.d.ts.map +1 -1
- package/types/analyze/index.d.ts +2 -0
- package/types/analyze/index.d.ts.map +1 -0
- package/types/analyze/solution.d.ts +14 -8
- package/types/analyze/solution.d.ts.map +1 -1
- package/types/coefficients/fraction.d.ts +14 -12
- package/types/coefficients/fraction.d.ts.map +1 -1
- package/types/coefficients/index.d.ts +1 -1
- package/types/coefficients/index.d.ts.map +1 -1
- package/types/coefficients/root.d.ts +3 -0
- package/types/coefficients/root.d.ts.map +1 -1
- package/types/geometry/TupleAbstract.d.ts +22 -0
- package/types/geometry/TupleAbstract.d.ts.map +1 -0
- package/types/geometry/TupleN.d.ts +24 -0
- package/types/geometry/TupleN.d.ts.map +1 -0
- package/types/geometry/circle.d.ts +26 -17
- package/types/geometry/circle.d.ts.map +1 -1
- package/types/geometry/geomMath.d.ts +2 -1
- package/types/geometry/geomMath.d.ts.map +1 -1
- package/types/geometry/index.d.ts.map +1 -1
- package/types/geometry/line.d.ts +21 -30
- package/types/geometry/line.d.ts.map +1 -1
- package/types/geometry/line3.d.ts +19 -19
- package/types/geometry/line3.d.ts.map +1 -1
- package/types/geometry/matrix.d.ts +11 -11
- package/types/geometry/plane3.d.ts +10 -10
- package/types/geometry/plane3.d.ts.map +1 -1
- package/types/geometry/point.d.ts +11 -6
- package/types/geometry/point.d.ts.map +1 -1
- package/types/geometry/triangle.d.ts +68 -23
- package/types/geometry/triangle.d.ts.map +1 -1
- package/types/geometry/vector.d.ts +24 -44
- package/types/geometry/vector.d.ts.map +1 -1
- package/types/index.d.ts +5 -4
- package/types/index.d.ts.map +1 -1
- package/types/numeric.d.ts.map +1 -1
- package/types/pimath.interface.d.ts +18 -24
- package/types/pimath.interface.d.ts.map +1 -1
- package/types/randomization/algebra/rndPolynom.d.ts.map +1 -1
- package/types/randomization/coefficient/rndFraction.d.ts +1 -1
- package/types/randomization/coefficient/rndFraction.d.ts.map +1 -1
- package/types/randomization/geometry/rndLine.d.ts.map +1 -1
- package/types/randomization/random.d.ts +3 -2
- package/types/randomization/random.d.ts.map +1 -1
- package/types/randomization/rndTypes.d.ts +15 -10
- package/types/randomization/rndTypes.d.ts.map +1 -1
- package/src/coefficients/nthRoot.ts +0 -149
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
// TODO: Remove NthRoot class
|
|
2
|
-
/**
|
|
3
|
-
* NthRoot is something like "a+b\sqrt{3}
|
|
4
|
-
*/
|
|
5
|
-
export class NthRoot {
|
|
6
|
-
#radical: number
|
|
7
|
-
#nth: number
|
|
8
|
-
#coefficient: number
|
|
9
|
-
#isValid: boolean
|
|
10
|
-
|
|
11
|
-
constructor(...values: number[]) {
|
|
12
|
-
this.#radical = 1
|
|
13
|
-
this.#coefficient = 1
|
|
14
|
-
this.#nth = 2
|
|
15
|
-
this.#isValid = true
|
|
16
|
-
|
|
17
|
-
if (values.length > 0) {
|
|
18
|
-
this.parse(values[0], values[1], values[2])
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// ------------------------------------------
|
|
23
|
-
// Getter and setter
|
|
24
|
-
// ------------------------------------------
|
|
25
|
-
get radical(): number {
|
|
26
|
-
return this.#radical
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
set radical(value: number) {
|
|
30
|
-
this.#radical = value
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
get nth(): number {
|
|
34
|
-
return this.#nth
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
set nth(value: number) {
|
|
38
|
-
if (Number.isSafeInteger(value) && value >= 2) {
|
|
39
|
-
this.#nth = value
|
|
40
|
-
} else {
|
|
41
|
-
// Error setting the nth root.
|
|
42
|
-
console.log('Error setting the nth root')
|
|
43
|
-
this.#nth = 2
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
get coefficient(): number {
|
|
48
|
-
return this.#coefficient
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
set coefficient(value: number) {
|
|
52
|
-
this.#coefficient = value
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
get tex(): string {
|
|
56
|
-
let C: string
|
|
57
|
-
|
|
58
|
-
if (this.#coefficient === 1) {
|
|
59
|
-
C = ''
|
|
60
|
-
} else if (this.#coefficient === -1) {
|
|
61
|
-
C = '-'
|
|
62
|
-
} else {
|
|
63
|
-
C = this.#coefficient.toString()
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (this.#radical === 1) {
|
|
67
|
-
return `${this.#coefficient}`
|
|
68
|
-
} else {
|
|
69
|
-
if (this.#nth === 2) {
|
|
70
|
-
return `${C}\\sqrt{${this.#radical}}`
|
|
71
|
-
} else {
|
|
72
|
-
return `${C}\\sqrt[${this.#nth}]{${this.#radical}}`
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
get display(): string {
|
|
78
|
-
let C: string
|
|
79
|
-
|
|
80
|
-
if (this.#coefficient === 1) {
|
|
81
|
-
C = ''
|
|
82
|
-
} else if (this.#coefficient === -1) {
|
|
83
|
-
C = '-'
|
|
84
|
-
} else {
|
|
85
|
-
C = this.#coefficient.toString()
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (this.#radical === 1) {
|
|
89
|
-
return `${this.#coefficient}`
|
|
90
|
-
} else {
|
|
91
|
-
if (this.#nth === 2) {
|
|
92
|
-
return `${C}sqrt{${this.#radical}}`
|
|
93
|
-
} else {
|
|
94
|
-
return `${C}root(${this.#nth}){${this.#radical}}`
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
get value(): number {
|
|
100
|
-
return this.#coefficient * Math.pow(this.#radical, 1 / this.#nth)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// ------------------------------------------
|
|
104
|
-
// Creation / parsing functions
|
|
105
|
-
// ------------------------------------------
|
|
106
|
-
parse = (radical: number, nthroot?: number, coefficient?: number): this => {
|
|
107
|
-
this.#coefficient = coefficient ?? 1
|
|
108
|
-
this.#nth = nthroot ?? 2
|
|
109
|
-
this.#radical = radical
|
|
110
|
-
|
|
111
|
-
if (this.#nth % 2 === 0 && this.#radical < 0) {
|
|
112
|
-
this.#isValid = false
|
|
113
|
-
}
|
|
114
|
-
return this
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// ------------------------------------------
|
|
118
|
-
// Mathematical operations
|
|
119
|
-
// ------------------------------------------
|
|
120
|
-
reduce = (): this => {
|
|
121
|
-
// Max value to test.
|
|
122
|
-
let V = Math.floor(Math.pow(this.#radical, 1 / this.#nth))
|
|
123
|
-
while (V > 1) {
|
|
124
|
-
if (this.#radical % Math.pow(V, this.#nth) === 0) {
|
|
125
|
-
// It's dividable by V^n
|
|
126
|
-
this.#coefficient *= V
|
|
127
|
-
this.#radical = this.#radical / Math.pow(V, this.#nth)
|
|
128
|
-
|
|
129
|
-
// Redifine the new testing value (this is optimization)
|
|
130
|
-
V = Math.floor(Math.pow(this.#radical, 1 / this.#nth))
|
|
131
|
-
continue
|
|
132
|
-
}
|
|
133
|
-
V--
|
|
134
|
-
}
|
|
135
|
-
return this
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
multiply = (N: NthRoot): this => {
|
|
139
|
-
this.#radical *= N.radical
|
|
140
|
-
return this.reduce()
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// ------------------------------------------
|
|
144
|
-
// Help functions
|
|
145
|
-
// ------------------------------------------
|
|
146
|
-
hasRadical = (): boolean => {
|
|
147
|
-
return !(this.#radical === 1 || this.#radical === 0 || !this.#isValid)
|
|
148
|
-
}
|
|
149
|
-
}
|