math-exercises 3.0.123 → 3.0.125
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/lib/exercises/math/calcul/arithmetics/primeNumbers.d.ts +1 -1
- package/lib/exercises/math/calcul/arithmetics/primeNumbers.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/primeNumbers.js +20 -14
- package/lib/exercises/math/calcul/fractions/fractionsMix.js +1 -1
- package/lib/exercises/math/conversion/volumeConversion.d.ts.map +1 -1
- package/lib/exercises/math/conversion/volumeConversion.js +7 -1
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.d.ts.map +1 -1
- package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.js +9 -3
- package/lib/exercises/math/functions/affines/affineFromExercise.d.ts +1 -1
- package/lib/exercises/math/functions/affines/affineFromExercise.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineFromExercise.js +123 -48
- package/lib/exercises/math/functions/affines/drawAffineFromLitExp.js +5 -5
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.d.ts +2 -1
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/recognizeAffineGraph.js +41 -24
- package/lib/exercises/math/functions/basics/findZeroesProductQuotient.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/findZeroesProductQuotient.js +29 -2
- package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/inverseImageFunctionGeogebra.js +72 -61
- package/lib/exercises/math/functions/logarithm/powerEquation.d.ts.map +1 -1
- package/lib/exercises/math/functions/logarithm/powerEquation.js +0 -1
- package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/roots/rootsFromDevForm.js +41 -16
- package/lib/exercises/math/functions/trinoms/roots/rootsReading.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/roots/rootsReading.js +3 -2
- package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts +1 -0
- package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/sign/trinomSignFromFacto.js +21 -13
- package/lib/exercises/math/geometry/perimeters/circleCircumference.d.ts.map +1 -1
- package/lib/exercises/math/geometry/perimeters/circleCircumference.js +15 -7
- package/lib/exercises/math/geometry/shapes/basicShapesNaming.d.ts.map +1 -1
- package/lib/exercises/math/geometry/shapes/basicShapesNaming.js +5 -3
- package/lib/exercises/math/geometry/vectors/vectorLinearCombination.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/vectorLinearCombination.js +0 -1
- package/lib/exercises/math/percent/evolutions/evolutionToCM.js +2 -2
- package/lib/exercises/math/percent/findProportion.d.ts +6 -1
- package/lib/exercises/math/percent/findProportion.d.ts.map +1 -1
- package/lib/exercises/math/percent/findProportion.js +162 -45
- package/lib/exercises/math/powers/calculateNegativePower.d.ts +5 -1
- package/lib/exercises/math/powers/calculateNegativePower.d.ts.map +1 -1
- package/lib/exercises/math/powers/calculateNegativePower.js +93 -29
- package/lib/exercises/math/probaStat/probaFromTableNoContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableNoContext.js +10 -2
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +2 -1
- package/lib/exercises/math/probaStat/stats1var/quartilesList.d.ts +4 -1
- package/lib/exercises/math/probaStat/stats1var/quartilesList.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/quartilesList.js +46 -27
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricFindExplicitFormula.js +14 -2
- package/lib/exercises/math/sequences/geometric/geometricReasonUsage.d.ts +1 -0
- package/lib/exercises/math/sequences/geometric/geometricReasonUsage.d.ts.map +1 -1
- package/lib/exercises/math/sequences/geometric/geometricReasonUsage.js +43 -19
- package/lib/exercises/math/sequences/sequenceEvaluation.d.ts.map +1 -1
- package/lib/exercises/math/sequences/sequenceEvaluation.js +18 -1
- package/lib/exercises/pc/chemicalReactions/chemicalEquations.d.ts.map +1 -1
- package/lib/exercises/pc/chemicalReactions/chemicalEquations.js +17 -2
- package/lib/exercises/pc/mole/molarMass.d.ts.map +1 -1
- package/lib/exercises/pc/mole/molarMass.js +7 -1
- package/lib/exercises/pc/motion/averageSpeed.d.ts +9 -4
- package/lib/exercises/pc/motion/averageSpeed.d.ts.map +1 -1
- package/lib/exercises/pc/motion/averageSpeed.js +132 -61
- package/lib/exercises/pc/motion/averageSpeedCalculation.d.ts.map +1 -1
- package/lib/exercises/pc/motion/averageSpeedCalculation.js +10 -4
- package/lib/exercises/pc/recognizeRefractionOrReflectionAngles.d.ts +2 -2
- package/lib/exercises/pc/recognizeRefractionOrReflectionAngles.js +15 -15
- package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts +1 -0
- package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts.map +1 -1
- package/lib/exercises/utils/geogebra/toolBarConstructor.js +3 -1
- package/lib/index.d.ts +49 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/pc/units/timeUnits.d.ts +5 -3
- package/lib/pc/units/timeUnits.d.ts.map +1 -1
- package/lib/pc/units/timeUnits.js +25 -19
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ const getAnswer = (identifiers) => {
|
|
|
22
22
|
return isAsking;
|
|
23
23
|
};
|
|
24
24
|
const getGGBOptions = (identifiers) => {
|
|
25
|
-
const { isAsking,
|
|
25
|
+
const { isAsking, enteringLightX, enteringLightY } = identifiers;
|
|
26
26
|
let angle = "";
|
|
27
27
|
switch (isAsking) {
|
|
28
28
|
case IsAsking.RefractionAngle:
|
|
@@ -33,24 +33,24 @@ const getGGBOptions = (identifiers) => {
|
|
|
33
33
|
break;
|
|
34
34
|
case IsAsking.IncidenceAngle:
|
|
35
35
|
default:
|
|
36
|
-
angle = `Ang = Angle(Line((0,0), (0,5)),Line((0,0),(${
|
|
36
|
+
angle = `Ang = Angle(Line((0,0), (0,5)),Line((0,0),(${enteringLightX},${enteringLightY})))`;
|
|
37
37
|
}
|
|
38
|
-
const reflectionLight = { x2: -
|
|
38
|
+
const reflectionLight = { x2: -enteringLightX, y2: enteringLightY };
|
|
39
39
|
const refractingLight = {
|
|
40
40
|
x2: reflectionLight.x2 - randint(5, 10),
|
|
41
41
|
y2: -reflectionLight.y2,
|
|
42
42
|
};
|
|
43
43
|
const commands = [
|
|
44
|
-
`E = Vector((${
|
|
44
|
+
`E = Vector((${enteringLightX},${enteringLightY}), (0,0))`,
|
|
45
45
|
`R = Vector((0,0), (${reflectionLight.x2},${reflectionLight.y2}))`,
|
|
46
46
|
`I = Vector((0,0), (${refractingLight.x2},${refractingLight.y2}))`,
|
|
47
47
|
angle,
|
|
48
48
|
`DashedLine = Line((0,0),(0,5))`,
|
|
49
49
|
`Y = Line((0,0),(5,0))`,
|
|
50
|
-
`Text("\\tiny \\text{Surface de séparation}", (-12,0),false,true)`,
|
|
51
|
-
`Text("\\tiny \\text{Milieu 1}", (9,2.5),false,true)`,
|
|
52
|
-
`Text("\\tiny \\text{Milieu 2}", (9,0),false,true)`,
|
|
53
|
-
`YText = Text(RotateText("\\tiny \\text{Rayon incident}",-90
|
|
50
|
+
`SSurfaceText = Text("\\tiny \\text{Surface de séparation}", (-12,0),false,true)`,
|
|
51
|
+
`M1Text = Text("\\tiny \\text{Milieu 1}", (9,2.5),false,true)`,
|
|
52
|
+
`M2Text= Text("\\tiny \\text{Milieu 2}", (9,0),false,true)`,
|
|
53
|
+
`YText = Text(RotateText("\\tiny \\text{Rayon incident}",-90°+Ang), (${enteringLightX / 2 - 1.5},${enteringLightY / 2}),false,true)`,
|
|
54
54
|
`SetLineStyle(DashedLine,2)`,
|
|
55
55
|
`ShowLabel(Ang,false)`,
|
|
56
56
|
`SetColor(E,"#F78D04")`,
|
|
@@ -62,10 +62,10 @@ const getGGBOptions = (identifiers) => {
|
|
|
62
62
|
`SetFixed(I,true)`,
|
|
63
63
|
`SetFixed(DashedLine,true)`,
|
|
64
64
|
`SetFixed(Y,true)`,
|
|
65
|
-
`
|
|
66
|
-
`
|
|
67
|
-
`SetColor(
|
|
68
|
-
`SetColor(
|
|
65
|
+
`FirstPolygon = Polygon((15, 0), (15,12), (-15, 12), (-15, 0))`,
|
|
66
|
+
`SecondPolygon = Polygon((15, 0), (15,-12), (-15, -12), (-15, 0))`,
|
|
67
|
+
`SetColor(FirstPolygon,"${blueMain}")`,
|
|
68
|
+
`SetColor(SecondPolygon,"#0a6a01")`,
|
|
69
69
|
`SetColor(Ang,"#6a0101")`,
|
|
70
70
|
];
|
|
71
71
|
const ggb = new GeogebraConstructor({
|
|
@@ -90,10 +90,10 @@ const getQuestionFromIdentifiers = (identifiers) => {
|
|
|
90
90
|
return question;
|
|
91
91
|
};
|
|
92
92
|
const getRecognizeRefractionOrReflectionAnglesQuestion = () => {
|
|
93
|
-
const
|
|
94
|
-
const
|
|
93
|
+
const enteringLightX = randint(-20, -10);
|
|
94
|
+
const enteringLightY = randint(15, 21);
|
|
95
95
|
const isAsking = random(questionAngle);
|
|
96
|
-
const identifiers = { isAsking,
|
|
96
|
+
const identifiers = { isAsking, enteringLightX, enteringLightY };
|
|
97
97
|
return getQuestionFromIdentifiers(identifiers);
|
|
98
98
|
};
|
|
99
99
|
const getPropositions = (n, { answer }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolBarConstructor.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/toolBarConstructor.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,GAAI,SAAS;IAC1C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"toolBarConstructor.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/toolBarConstructor.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,GAAI,SAAS;IAC1C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,WAgBA,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare const mathExercises: (Exercise<{
|
|
|
18
18
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
19
19
|
nb: number;
|
|
20
20
|
}, {
|
|
21
|
-
|
|
21
|
+
asPowers?: boolean;
|
|
22
22
|
}, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
23
23
|
a: number;
|
|
24
24
|
b: number;
|
|
@@ -842,7 +842,7 @@ declare const mathExercises: (Exercise<{
|
|
|
842
842
|
yA: number;
|
|
843
843
|
yB: number;
|
|
844
844
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
845
|
-
|
|
845
|
+
situationIndex: number;
|
|
846
846
|
initial: number;
|
|
847
847
|
growth: number;
|
|
848
848
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
@@ -850,13 +850,14 @@ declare const mathExercises: (Exercise<{
|
|
|
850
850
|
pointIdsB: import("./math/geometry/point.js").PointIdentifiers;
|
|
851
851
|
funcName: string;
|
|
852
852
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
853
|
-
arrNodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers[];
|
|
854
853
|
arrFProps: {
|
|
855
854
|
fName: string;
|
|
856
855
|
colorProps: {
|
|
857
856
|
strFrench: string;
|
|
858
857
|
hashRgb: string;
|
|
859
858
|
};
|
|
859
|
+
nodeIds: import("./tree/nodes/nodeConstructor.js").NodeIdentifiers;
|
|
860
|
+
isAnswer: boolean;
|
|
860
861
|
}[];
|
|
861
862
|
isLinear: boolean;
|
|
862
863
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
@@ -1029,6 +1030,7 @@ declare const mathExercises: (Exercise<{
|
|
|
1029
1030
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
1030
1031
|
trinomCoeffs: number[];
|
|
1031
1032
|
isAskingPositive: boolean;
|
|
1033
|
+
isStrict: boolean;
|
|
1032
1034
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
1033
1035
|
param: string;
|
|
1034
1036
|
coeffs: number[];
|
|
@@ -1859,9 +1861,15 @@ declare const mathExercises: (Exercise<{
|
|
|
1859
1861
|
percent: number;
|
|
1860
1862
|
nb: number;
|
|
1861
1863
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
1864
|
+
indexSituation: number;
|
|
1862
1865
|
total: number;
|
|
1863
1866
|
lefties: number;
|
|
1864
|
-
|
|
1867
|
+
opts: {
|
|
1868
|
+
isPercentSymbolRequired: boolean;
|
|
1869
|
+
};
|
|
1870
|
+
}, {
|
|
1871
|
+
isPercentSymbolRequired: boolean;
|
|
1872
|
+
}, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
1865
1873
|
TVA: number;
|
|
1866
1874
|
ht: number;
|
|
1867
1875
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
@@ -1936,7 +1944,12 @@ declare const mathExercises: (Exercise<{
|
|
|
1936
1944
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
1937
1945
|
int: number;
|
|
1938
1946
|
power: number;
|
|
1939
|
-
|
|
1947
|
+
opts: {
|
|
1948
|
+
isPowerAllowed: boolean;
|
|
1949
|
+
};
|
|
1950
|
+
}, {
|
|
1951
|
+
isPowerAllowed: boolean;
|
|
1952
|
+
}, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
1940
1953
|
int: number;
|
|
1941
1954
|
power: number;
|
|
1942
1955
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
@@ -2052,7 +2065,9 @@ declare const mathExercises: (Exercise<{
|
|
|
2052
2065
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
2053
2066
|
randomValues: number[];
|
|
2054
2067
|
randomQuartile: number;
|
|
2055
|
-
},
|
|
2068
|
+
}, {
|
|
2069
|
+
nbValues: number;
|
|
2070
|
+
}, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
2056
2071
|
sortedValues: number[];
|
|
2057
2072
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
2058
2073
|
sortedValues: number[];
|
|
@@ -2316,6 +2331,7 @@ declare const mathExercises: (Exercise<{
|
|
|
2316
2331
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
2317
2332
|
reason: number;
|
|
2318
2333
|
startRank: number;
|
|
2334
|
+
askedRank: number;
|
|
2319
2335
|
startValue: number;
|
|
2320
2336
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
2321
2337
|
firstValue: number;
|
|
@@ -2679,8 +2695,8 @@ declare const mathExercises: (Exercise<{
|
|
|
2679
2695
|
height: number;
|
|
2680
2696
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
2681
2697
|
isAsking: string;
|
|
2682
|
-
|
|
2683
|
-
|
|
2698
|
+
enteringLightX: number;
|
|
2699
|
+
enteringLightY: number;
|
|
2684
2700
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
2685
2701
|
randomMaterial1: number;
|
|
2686
2702
|
randomMaterial2: number;
|
|
@@ -2919,7 +2935,14 @@ declare const mathExercises: (Exercise<{
|
|
|
2919
2935
|
value: number;
|
|
2920
2936
|
unitIndex: number;
|
|
2921
2937
|
};
|
|
2922
|
-
|
|
2938
|
+
opts: {
|
|
2939
|
+
acceptedInputType: string;
|
|
2940
|
+
unitTex: string;
|
|
2941
|
+
};
|
|
2942
|
+
}, {
|
|
2943
|
+
acceptedInputType: string;
|
|
2944
|
+
unitTex: string;
|
|
2945
|
+
}, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
2923
2946
|
speed: number;
|
|
2924
2947
|
distance: number;
|
|
2925
2948
|
deltaTime: number;
|
|
@@ -3080,9 +3103,15 @@ declare const pcExercises: (Exercise<{
|
|
|
3080
3103
|
trigoPoint: string;
|
|
3081
3104
|
letters: string[];
|
|
3082
3105
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
3106
|
+
indexSituation: number;
|
|
3083
3107
|
total: number;
|
|
3084
3108
|
lefties: number;
|
|
3085
|
-
|
|
3109
|
+
opts: {
|
|
3110
|
+
isPercentSymbolRequired: boolean;
|
|
3111
|
+
};
|
|
3112
|
+
}, {
|
|
3113
|
+
isPercentSymbolRequired: boolean;
|
|
3114
|
+
}, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
3086
3115
|
decimal: number;
|
|
3087
3116
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
3088
3117
|
a: number;
|
|
@@ -3138,8 +3167,8 @@ declare const pcExercises: (Exercise<{
|
|
|
3138
3167
|
height: number;
|
|
3139
3168
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
3140
3169
|
isAsking: string;
|
|
3141
|
-
|
|
3142
|
-
|
|
3170
|
+
enteringLightX: number;
|
|
3171
|
+
enteringLightY: number;
|
|
3143
3172
|
}, object, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
3144
3173
|
randomMaterial1: number;
|
|
3145
3174
|
randomMaterial2: number;
|
|
@@ -3378,7 +3407,14 @@ declare const pcExercises: (Exercise<{
|
|
|
3378
3407
|
value: number;
|
|
3379
3408
|
unitIndex: number;
|
|
3380
3409
|
};
|
|
3381
|
-
|
|
3410
|
+
opts: {
|
|
3411
|
+
acceptedInputType: string;
|
|
3412
|
+
unitTex: string;
|
|
3413
|
+
};
|
|
3414
|
+
}, {
|
|
3415
|
+
acceptedInputType: string;
|
|
3416
|
+
unitTex: string;
|
|
3417
|
+
}, string | number | boolean | string[] | number[] | boolean[]> | Exercise<{
|
|
3382
3418
|
speed: number;
|
|
3383
3419
|
distance: number;
|
|
3384
3420
|
deltaTime: number;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM,2BAA2B,CAAC;AAE3D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0EAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0EAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../../tree/nodes/algebraicNode.js";
|
|
1
2
|
import { Measure } from "../measure/measure.js";
|
|
2
3
|
import { BasicUnit } from "./interfaces/basicUnit.js";
|
|
3
|
-
export type TimeValues = "h" | "
|
|
4
|
+
export type TimeValues = "h" | "min" | "s" | "ms";
|
|
4
5
|
export declare class TimeUnit extends BasicUnit<TimeValues> {
|
|
5
6
|
static readonly h: TimeUnit;
|
|
6
|
-
static readonly
|
|
7
|
+
static readonly min: TimeUnit;
|
|
7
8
|
static readonly s: TimeUnit;
|
|
8
9
|
static readonly ms: TimeUnit;
|
|
9
10
|
className(): string;
|
|
10
11
|
convert(significantPart: number, exponent: number, convertToUnit: TimeValues): Measure<TimeValues>;
|
|
11
|
-
convertToMinute(
|
|
12
|
+
static convertToMinute(unit: TimeValues): AlgebraicNode;
|
|
13
|
+
static getConversionFactor(from: TimeValues, to: TimeValues): import("../../tree/nodes/operators/fractionNode.js").FractionNode;
|
|
12
14
|
}
|
|
13
15
|
//# sourceMappingURL=timeUnits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeUnits.d.ts","sourceRoot":"","sources":["../../../src/pc/units/timeUnits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,
|
|
1
|
+
{"version":3,"file":"timeUnits.d.ts","sourceRoot":"","sources":["../../../src/pc/units/timeUnits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC;AAKlD,qBAAa,QAAS,SAAQ,SAAS,CAAC,UAAU,CAAC;IACjD,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAqB;IACtC,MAAM,CAAC,QAAQ,CAAC,GAAG,WAAuB;IAC1C,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAqB;IACtC,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAsB;IAExC,SAAS,IAAI,MAAM;IAInB,OAAO,CACL,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,UAAU,GACxB,OAAO,CAAC,UAAU,CAAC;IAiBtB,MAAM,CAAC,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,aAAa;IAavD,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU;CAG5D"}
|
|
@@ -1,38 +1,44 @@
|
|
|
1
|
+
import { frac } from "../../tree/nodes/operators/fractionNode.js";
|
|
2
|
+
import { multiply } from "../../tree/nodes/operators/multiplyNode.js";
|
|
1
3
|
import { Measure } from "../measure/measure.js";
|
|
2
4
|
import { BasicUnit } from "./interfaces/basicUnit.js";
|
|
3
|
-
const times = ["h", "
|
|
5
|
+
const times = ["h", "min", "s", "ms"];
|
|
4
6
|
// const timesValue = [1 / 60, 1, 60, 60000];
|
|
5
7
|
export class TimeUnit extends BasicUnit {
|
|
6
8
|
static h = new TimeUnit("h");
|
|
7
|
-
static
|
|
9
|
+
static min = new TimeUnit("min");
|
|
8
10
|
static s = new TimeUnit("s");
|
|
9
11
|
static ms = new TimeUnit("ms");
|
|
10
12
|
className() {
|
|
11
13
|
return "TimeUnit";
|
|
12
14
|
}
|
|
13
15
|
convert(significantPart, exponent, convertToUnit) {
|
|
14
|
-
const timeObjects = [TimeUnit.h, TimeUnit.
|
|
16
|
+
const timeObjects = [TimeUnit.h, TimeUnit.min, TimeUnit.s, TimeUnit.ms];
|
|
15
17
|
const unitIndex = times.findIndex((value) => convertToUnit === value);
|
|
16
|
-
if (!
|
|
18
|
+
if (!unitIndex) {
|
|
17
19
|
throw new Error(`cannot convert ${this.toTex()} to ${convertToUnit}.`);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const timeObject = timeObjects[unitIndex];
|
|
23
|
+
const factor = TimeUnit.getConversionFactor(this.unit, convertToUnit);
|
|
24
|
+
//!TODO: precision loss here /!\
|
|
25
|
+
const significantPartTo = multiply(significantPart, factor).evaluate();
|
|
26
|
+
return new Measure(significantPartTo, exponent, timeObject);
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
|
-
convertToMinute(
|
|
26
|
-
switch (
|
|
29
|
+
static convertToMinute(unit) {
|
|
30
|
+
switch (unit) {
|
|
27
31
|
case "h":
|
|
28
|
-
return
|
|
29
|
-
case "
|
|
30
|
-
return
|
|
31
|
-
case "s
|
|
32
|
-
return
|
|
32
|
+
return (60).toTree();
|
|
33
|
+
case "min":
|
|
34
|
+
return (1).toTree();
|
|
35
|
+
case "s":
|
|
36
|
+
return frac(1, 60);
|
|
33
37
|
case "ms":
|
|
34
|
-
return
|
|
38
|
+
return frac(1, 60_000);
|
|
35
39
|
}
|
|
36
|
-
|
|
40
|
+
}
|
|
41
|
+
static getConversionFactor(from, to) {
|
|
42
|
+
return frac(TimeUnit.convertToMinute(from), TimeUnit.convertToMinute(to));
|
|
37
43
|
}
|
|
38
44
|
}
|