import React, { useState } from 'react'; const StandardFormWidget: React.FC = () => { const [A, setA] = useState(2); const [B, setB] = useState(3); const [C, setC] = useState(12); // Intercepts const xInt = A !== 0 ? C / A : null; const yInt = B !== 0 ? C / B : null; // Vis const range = 15; const scale = 15; const center = 150; const toPx = (val: number, isY = false) => isY ? center - val * scale : center + val * scale; // Line points // If B!=0, y = (C - Ax)/B. If A!=0, x = (C - By)/A. let p1, p2; if (B !== 0) { p1 = { x: -range, y: (C - A * -range) / B }; p2 = { x: range, y: (C - A * range) / B }; } else { // Vertical line x = C/A p1 = { x: C/A, y: -range }; p2 = { x: C/A, y: range }; } return (
{A}x + {B}y = {C}
setA(Number(e.target.value))} className="w-full p-1 border rounded text-center font-bold"/>
setB(Number(e.target.value))} className="w-full p-1 border rounded text-center font-bold"/>
setC(Number(e.target.value))} className="w-full p-1 border rounded text-center font-bold"/>

Cover-Up Method

Find X-Intercept (Set y=0)

{A}x = {C}
x = {C} / {A}
x = {xInt !== null ? xInt.toFixed(2) : 'Undefined'}

Find Y-Intercept (Set x=0)

{B}y = {C}
y = {C} / {B}
y = {yInt !== null ? yInt.toFixed(2) : 'Undefined'}
{/* Grid */} {/* Axes */} {/* Line */} {/* Intercepts */} {xInt !== null && Math.abs(xInt) <= range && ( {xInt.toFixed(1)} )} {yInt !== null && Math.abs(yInt) <= range && ( {yInt.toFixed(1)} )}
); }; export default StandardFormWidget;