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.
Files changed (99) hide show
  1. package/dist/pimath.js +3106 -2873
  2. package/dist/pimath.js.map +1 -1
  3. package/package.json +13 -11
  4. package/src/algebra/equation.ts +113 -111
  5. package/src/algebra/equationSolver.ts +69 -120
  6. package/src/algebra/factor.ts +6 -7
  7. package/src/algebra/linearSystem.ts +97 -46
  8. package/src/algebra/logicalset.ts +51 -52
  9. package/src/algebra/monom.ts +23 -61
  10. package/src/algebra/operations.ts +0 -1
  11. package/src/algebra/polyFactor.ts +5 -5
  12. package/src/algebra/polynom.ts +69 -216
  13. package/src/analyze/index.ts +4 -0
  14. package/src/analyze/solution.ts +92 -29
  15. package/src/analyze/tableOfSigns.ts +1 -1
  16. package/src/coefficients/fraction.ts +189 -149
  17. package/src/coefficients/index.ts +1 -1
  18. package/src/coefficients/root.ts +66 -19
  19. package/src/geometry/TupleN.ts +128 -0
  20. package/src/geometry/circle.ts +308 -238
  21. package/src/geometry/geomMath.ts +4 -3
  22. package/src/geometry/index.ts +1 -0
  23. package/src/geometry/line.ts +221 -245
  24. package/src/geometry/line3.ts +78 -73
  25. package/src/geometry/plane3.ts +64 -55
  26. package/src/geometry/point.ts +57 -19
  27. package/src/geometry/triangle.ts +376 -248
  28. package/src/geometry/vector.ts +113 -229
  29. package/src/index.ts +13 -12
  30. package/src/numeric.ts +6 -9
  31. package/src/pimath.interface.ts +30 -28
  32. package/src/randomization/algebra/rndPolynom.ts +29 -15
  33. package/src/randomization/coefficient/rndFraction.ts +3 -3
  34. package/src/randomization/geometry/rndLine.ts +8 -10
  35. package/src/randomization/random.ts +11 -13
  36. package/src/randomization/rndTypes.ts +16 -12
  37. package/types/algebra/equation.d.ts +18 -17
  38. package/types/algebra/equation.d.ts.map +1 -1
  39. package/types/algebra/equationSolver.d.ts +5 -4
  40. package/types/algebra/equationSolver.d.ts.map +1 -1
  41. package/types/algebra/factor.d.ts +1 -1
  42. package/types/algebra/factor.d.ts.map +1 -1
  43. package/types/algebra/linearSystem.d.ts +23 -6
  44. package/types/algebra/linearSystem.d.ts.map +1 -1
  45. package/types/algebra/logicalset.d.ts +1 -1
  46. package/types/algebra/logicalset.d.ts.map +1 -1
  47. package/types/algebra/monom.d.ts +1 -6
  48. package/types/algebra/monom.d.ts.map +1 -1
  49. package/types/algebra/operations.d.ts.map +1 -1
  50. package/types/algebra/polyFactor.d.ts +4 -4
  51. package/types/algebra/polyFactor.d.ts.map +1 -1
  52. package/types/algebra/polynom.d.ts +10 -7
  53. package/types/algebra/polynom.d.ts.map +1 -1
  54. package/types/analyze/index.d.ts +2 -0
  55. package/types/analyze/index.d.ts.map +1 -0
  56. package/types/analyze/solution.d.ts +14 -8
  57. package/types/analyze/solution.d.ts.map +1 -1
  58. package/types/coefficients/fraction.d.ts +14 -12
  59. package/types/coefficients/fraction.d.ts.map +1 -1
  60. package/types/coefficients/index.d.ts +1 -1
  61. package/types/coefficients/index.d.ts.map +1 -1
  62. package/types/coefficients/root.d.ts +3 -0
  63. package/types/coefficients/root.d.ts.map +1 -1
  64. package/types/geometry/TupleAbstract.d.ts +22 -0
  65. package/types/geometry/TupleAbstract.d.ts.map +1 -0
  66. package/types/geometry/TupleN.d.ts +24 -0
  67. package/types/geometry/TupleN.d.ts.map +1 -0
  68. package/types/geometry/circle.d.ts +26 -17
  69. package/types/geometry/circle.d.ts.map +1 -1
  70. package/types/geometry/geomMath.d.ts +2 -1
  71. package/types/geometry/geomMath.d.ts.map +1 -1
  72. package/types/geometry/index.d.ts.map +1 -1
  73. package/types/geometry/line.d.ts +21 -30
  74. package/types/geometry/line.d.ts.map +1 -1
  75. package/types/geometry/line3.d.ts +19 -19
  76. package/types/geometry/line3.d.ts.map +1 -1
  77. package/types/geometry/matrix.d.ts +11 -11
  78. package/types/geometry/plane3.d.ts +10 -10
  79. package/types/geometry/plane3.d.ts.map +1 -1
  80. package/types/geometry/point.d.ts +11 -6
  81. package/types/geometry/point.d.ts.map +1 -1
  82. package/types/geometry/triangle.d.ts +68 -23
  83. package/types/geometry/triangle.d.ts.map +1 -1
  84. package/types/geometry/vector.d.ts +24 -44
  85. package/types/geometry/vector.d.ts.map +1 -1
  86. package/types/index.d.ts +5 -4
  87. package/types/index.d.ts.map +1 -1
  88. package/types/numeric.d.ts.map +1 -1
  89. package/types/pimath.interface.d.ts +18 -24
  90. package/types/pimath.interface.d.ts.map +1 -1
  91. package/types/randomization/algebra/rndPolynom.d.ts.map +1 -1
  92. package/types/randomization/coefficient/rndFraction.d.ts +1 -1
  93. package/types/randomization/coefficient/rndFraction.d.ts.map +1 -1
  94. package/types/randomization/geometry/rndLine.d.ts.map +1 -1
  95. package/types/randomization/random.d.ts +3 -2
  96. package/types/randomization/random.d.ts.map +1 -1
  97. package/types/randomization/rndTypes.d.ts +15 -10
  98. package/types/randomization/rndTypes.d.ts.map +1 -1
  99. 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
- }