diff --git a/src/lib/angleCalculator.ts b/src/lib/angleCalculator.ts index 4dd96de..324cac4 100644 --- a/src/lib/angleCalculator.ts +++ b/src/lib/angleCalculator.ts @@ -9,14 +9,18 @@ export const AngleCalculator = { * b: left, * c: ypoteinousa */ + const a = parseFloat(centerWidth) + const b = parseFloat(leftWidth) + const c = parseFloat(ypotinousa) + const cosC = - (Math.pow(centerWidth, 2) + - Math.pow(leftWidth, 2) - - Math.pow(ypotinousa, 2)) / - (2 * centerWidth * leftWidth); + (Math.pow(a, 2) + + Math.pow(b, 2) - + Math.pow(c, 2)) / + (2 * a * b); - const c = Math.acos(cosC); + const angleRad = Math.acos(cosC); const arcConst = 180 / Math.PI; - return (c * arcConst) + return (angleRad * arcConst) }, }; diff --git a/src/models/calculator.ts b/src/models/calculator.ts index 27aa02b..8148ede 100644 --- a/src/models/calculator.ts +++ b/src/models/calculator.ts @@ -17,9 +17,9 @@ export interface ICalcResults { } export interface IAngleCalcInputs { - centerWidth: number; - leftWidth: number; - ypotinousa: number; + centerWidth: string; + leftWidth: string; + ypotinousa: string; } export interface IAngleCalcResults { diff --git a/src/pages/Triples/InputsCard.tsx b/src/pages/Triples/InputsCard.tsx index 6b99436..224796f 100644 --- a/src/pages/Triples/InputsCard.tsx +++ b/src/pages/Triples/InputsCard.tsx @@ -26,7 +26,7 @@ const InputsCard: React.FC = (props) => { } = props; const handleChange = (e: React.ChangeEvent) => { - const value = parseFloat(e.target.value); + const value = e.target.value; const id = e.target.id; // if (!value) return;