import React, { useState } from 'react'; const RationalExplorer: React.FC = () => { const [cancelFactor, setCancelFactor] = useState(false); // If true, (x-2) is in numerator // Base function f(x) = (x+1) / [(x-2)(x+1)] ? No simple case. // Let's do: f(x) = (x+1) * [ (x-2) if cancel ] / [ (x-2) * (x-3) ] // If cancel: f(x) = (x+1)/(x-3) with Hole at 2. // If not cancel: f(x) = (x+1) / [(x-2)(x-3)] ... complex. // Better example: f(x) = [numerator] / (x-2) // Numerator options: (x-2) -> Hole. 1 -> VA. const width = 300; const height = 200; const range = 6; const scale = width / (range * 2); const center = width / 2; const toPx = (v: number, isY = false) => isY ? height/2 - v * scale : center + v * scale; const generatePath = () => { let d = ""; for (let x = -range; x <= range; x += 0.05) { if (Math.abs(x - 2) < 0.1) continue; // Skip near discontinuity let y = 0; if (cancelFactor) { // f(x) = (x-2) / (x-2) = 1 y = 1; } else { // f(x) = 1 / (x-2) y = 1 / (x - 2); } if (Math.abs(y) > range) { d += ` M `; // Break path continue; } const px = toPx(x); const py = toPx(y, true); d += d.endsWith('M ') ? `${px} ${py}` : ` L ${px} ${py}`; } return d; }; return (