pimath 0.0.18 → 0.0.19
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/index.html +2 -0
- package/dev/pi.js +53 -21
- package/dev/pi.js.map +1 -1
- package/dist/pi.js +1 -1
- package/dist/pi.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +1 -0
- package/esm/maths/algebra/equation.js +3 -0
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +4 -1
- package/esm/maths/geometry/circle.js +36 -21
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +2 -0
- package/esm/maths/geometry/line.js +14 -0
- package/esm/maths/geometry/line.js.map +1 -1
- package/package.json +1 -1
- package/src/maths/algebra/equation.ts +5 -0
- package/src/maths/geometry/circle.ts +53 -28
- package/src/maths/geometry/line.ts +17 -0
package/dev/index.html
CHANGED
package/dev/pi.js
CHANGED
|
@@ -84,6 +84,9 @@ class Equation {
|
|
|
84
84
|
get tex() {
|
|
85
85
|
return `${this._left.tex}${this.signAsTex}${this._right.tex}`;
|
|
86
86
|
}
|
|
87
|
+
get display() {
|
|
88
|
+
return `${this._left.display}${this.signAsTex}${this._right.display}`;
|
|
89
|
+
}
|
|
87
90
|
get raw() {
|
|
88
91
|
return `${this._left.raw}${this.signAsTex}${this._right.raw}`;
|
|
89
92
|
}
|
|
@@ -2941,27 +2944,6 @@ class Circle {
|
|
|
2941
2944
|
get center() {
|
|
2942
2945
|
return this._center;
|
|
2943
2946
|
}
|
|
2944
|
-
parse(...values) {
|
|
2945
|
-
if (values.length === 1 && typeof values[0] === 'string') {
|
|
2946
|
-
this.checkCircle(new algebra_1.Equation(values[0]));
|
|
2947
|
-
}
|
|
2948
|
-
else if (values.length >= 2) {
|
|
2949
|
-
this._center = new point_1.Point(values[0]);
|
|
2950
|
-
if (values[1] instanceof point_1.Point) {
|
|
2951
|
-
this._squareRadius = new vector_1.Vector(this._center, values[1]).normSquare;
|
|
2952
|
-
}
|
|
2953
|
-
else {
|
|
2954
|
-
if (values[2] === true) {
|
|
2955
|
-
this._squareRadius = new coefficients_1.Fraction(values[1]);
|
|
2956
|
-
}
|
|
2957
|
-
else {
|
|
2958
|
-
this._radius = new coefficients_1.Fraction(values[1]);
|
|
2959
|
-
this._squareRadius = this._radius.clone().pow(2);
|
|
2960
|
-
}
|
|
2961
|
-
}
|
|
2962
|
-
this._cartesian = (new algebra_1.Equation(new algebra_1.Polynom(`(x-(${this._center.x.display}))^2+(y-(${this._center.y.display}))^2`), new algebra_1.Polynom(`${this._squareRadius.display}`))).moveLeft();
|
|
2963
|
-
}
|
|
2964
|
-
}
|
|
2965
2947
|
get radius() {
|
|
2966
2948
|
if (this._squareRadius.isSquare()) {
|
|
2967
2949
|
return {
|
|
@@ -2996,6 +2978,33 @@ class Circle {
|
|
|
2996
2978
|
get developed() {
|
|
2997
2979
|
return this._cartesian.tex;
|
|
2998
2980
|
}
|
|
2981
|
+
get display() {
|
|
2982
|
+
return this._cartesian.display;
|
|
2983
|
+
}
|
|
2984
|
+
get cartesian() {
|
|
2985
|
+
return this._cartesian;
|
|
2986
|
+
}
|
|
2987
|
+
parse(...values) {
|
|
2988
|
+
if (values.length === 1 && typeof values[0] === 'string') {
|
|
2989
|
+
this.checkCircle(new algebra_1.Equation(values[0]));
|
|
2990
|
+
}
|
|
2991
|
+
else if (values.length >= 2) {
|
|
2992
|
+
this._center = new point_1.Point(values[0]);
|
|
2993
|
+
if (values[1] instanceof point_1.Point) {
|
|
2994
|
+
this._squareRadius = new vector_1.Vector(this._center, values[1]).normSquare;
|
|
2995
|
+
}
|
|
2996
|
+
else {
|
|
2997
|
+
if (values[2] === true) {
|
|
2998
|
+
this._squareRadius = new coefficients_1.Fraction(values[1]);
|
|
2999
|
+
}
|
|
3000
|
+
else {
|
|
3001
|
+
this._radius = new coefficients_1.Fraction(values[1]);
|
|
3002
|
+
this._squareRadius = this._radius.clone().pow(2);
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
this._cartesian = (new algebra_1.Equation(new algebra_1.Polynom(`(x-(${this._center.x.display}))^2+(y-(${this._center.y.display}))^2`), new algebra_1.Polynom(`${this._squareRadius.display}`))).moveLeft();
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
2999
3008
|
checkCircle = (P) => {
|
|
3000
3009
|
if (P.degree('x').value === 2 && P.degree('y').value === 2) {
|
|
3001
3010
|
let x2 = P.left.monomByDegree(2, 'x'), y2 = P.left.monomByDegree(2, 'y'), x1, y1, c;
|
|
@@ -3024,6 +3033,15 @@ class Circle {
|
|
|
3024
3033
|
return 2;
|
|
3025
3034
|
}
|
|
3026
3035
|
};
|
|
3036
|
+
lineIntersection = (L) => {
|
|
3037
|
+
let P1, P2;
|
|
3038
|
+
const equ = this._cartesian.clone(), yLine = L.equation.clone().isolate('y');
|
|
3039
|
+
if (yLine instanceof algebra_1.Equation) {
|
|
3040
|
+
equ.replaceBy('y', yLine.right);
|
|
3041
|
+
equ.solve();
|
|
3042
|
+
}
|
|
3043
|
+
return [];
|
|
3044
|
+
};
|
|
3027
3045
|
}
|
|
3028
3046
|
exports.Circle = Circle;
|
|
3029
3047
|
|
|
@@ -3341,6 +3359,20 @@ class Line {
|
|
|
3341
3359
|
}
|
|
3342
3360
|
return false;
|
|
3343
3361
|
}
|
|
3362
|
+
getValueAtX = (value) => {
|
|
3363
|
+
const equ = this.equation.clone().isolate('y');
|
|
3364
|
+
if (equ instanceof algebra_1.Equation) {
|
|
3365
|
+
return equ.right.evaluate({ x: value });
|
|
3366
|
+
}
|
|
3367
|
+
return;
|
|
3368
|
+
};
|
|
3369
|
+
getValueAtY = (value) => {
|
|
3370
|
+
const equ = this.equation.clone().isolate('x');
|
|
3371
|
+
if (equ instanceof algebra_1.Equation) {
|
|
3372
|
+
return equ.right.evaluate({ y: value });
|
|
3373
|
+
}
|
|
3374
|
+
return;
|
|
3375
|
+
};
|
|
3344
3376
|
canonicalAsFloatCoefficient(decimals) {
|
|
3345
3377
|
if (decimals === undefined) {
|
|
3346
3378
|
decimals = 2;
|