diff --git a/frontend/js/labs/trigcircle.js b/frontend/js/labs/trigcircle.js
index cadb45b..d609728 100644
--- a/frontend/js/labs/trigcircle.js
+++ b/frontend/js/labs/trigcircle.js
@@ -1106,18 +1106,23 @@ if (typeof window !== 'undefined') window.TrigCircleSim = TrigCircleSim;
fEl.innerHTML = 'Нетабличный угол — точных значений нет, см. приближённые выше.';
} else {
const reduce = (s.quadrant !== 1) && (beta === 30 || beta === 45 || beta === 60);
- let head = '';
+ const K = window.katex;
+ const tex = latex => (K ? K.renderToString(latex, { throwOnError: false, strict: false, displayMode: false }) : latex);
+ const FN = { sin: '\\sin', cos: '\\cos', tg: '\\operatorname{tg}', ctg: '\\operatorname{ctg}' };
+ let html = '';
if (reduce) {
- const wrap = s.quadrant === 2 ? `180° − ${beta}°` : s.quadrant === 3 ? `180° + ${beta}°` : `360° − ${beta}°`;
- head = `
${degR}° = ${wrap} → приведение к ${beta}°
`;
+ const wrap = s.quadrant === 2 ? `180^\\circ - ${beta}^\\circ`
+ : s.quadrant === 3 ? `180^\\circ + ${beta}^\\circ`
+ : `360^\\circ - ${beta}^\\circ`;
+ html += `${tex(`${degR}^\\circ = ${wrap}`)}
`;
}
- const sgStr = v => (v !== undefined && v < -1e-9) ? '−' : '';
const line = (nm, color, val) => {
- const mid = reduce ? ` = ${sgStr(val)}${nm} ${beta}°` : '';
- return `` +
- `${nm} ${degR}°${mid}${_f(val)}
`;
+ const sgn = (val !== undefined && val < -1e-9) ? '-' : '';
+ const mid = reduce ? ` = ${sgn}${FN[nm]}\\,${beta}^\\circ` : '';
+ // KaTeX наследует CSS-цвет родителя → красим div, формулу не трогаем.
+ return `${tex(`${FN[nm]}\\,${degR}^\\circ${mid} = ${_latexVal(val)}`)}
`;
};
- fEl.innerHTML = head + line('sin', '#EF476F', s.sin) + line('cos', '#06D6E0', s.cos) +
+ fEl.innerHTML = html + line('sin', '#EF476F', s.sin) + line('cos', '#06D6E0', s.cos) +
line('tg', '#FFD166', s.tan) + line('ctg', '#7BF5A4', s.cot);
}
}
@@ -1131,6 +1136,20 @@ if (typeof window !== 'undefined') window.TrigCircleSim = TrigCircleSim;
document.getElementById('trigbar-quad').textContent = ['I', 'II', 'III', 'IV'][s.quadrant - 1];
}
+ /* Точное значение → LaTeX (зеркалит _f, но для KaTeX). undefined → «—». */
+ function _latexVal(v) {
+ if (v === undefined) return '\\text{не опр.}';
+ const a = Math.abs(v), sg = v < -1e-9 ? '-' : '';
+ if (a < 5e-4) return '0';
+ if (Math.abs(a - 0.5) < 1e-3) return sg + '\\tfrac{1}{2}';
+ if (Math.abs(a - Math.SQRT2 / 2) < 1e-3) return sg + '\\tfrac{\\sqrt{2}}{2}';
+ if (Math.abs(a - Math.sqrt(3) / 2) < 1e-3) return sg + '\\tfrac{\\sqrt{3}}{2}';
+ if (Math.abs(a - Math.sqrt(3) / 3) < 1e-3) return sg + '\\tfrac{\\sqrt{3}}{3}';
+ if (Math.abs(a - 1) < 1e-3) return sg + '1';
+ if (Math.abs(a - Math.sqrt(3)) < 1e-3) return sg + '\\sqrt{3}';
+ return v.toFixed(3);
+ }
+
/* ── KaTeX live preview ── */
/** Convert user ascii expression LaTeX string for KaTeX preview */