edu-analytic-geometry
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese解析几何解题 → 交互网页
Analytic Geometry Problem Solving → Interactive Webpage
这个技能产出什么
What This Skill Produces
一个可直接用浏览器打开的单页 HTML(三栏):
- 左栏:题面 + 动态控制台 —— 一个可变参数滑块(如直线倾斜角 θ / 动点参数 t)驱动实时 重算的几何量(交点坐标、斜率、数量积、弦长、面积…),以及"理论范围条"或"定值指示"。
- 中栏:分步解析(公式用 KaTeX),可一键收起把空间让给画板。
- 右栏:2D Canvas 动态几何画板(圆锥曲线 + 动直线/动点 + 向量 + 点标注 + 网格坐标轴), 叠加画笔涂鸦工具栏。
形态与目标模板 一致。
/Users/wuyi/code/code2026/6/template/code_artifact.htmlA single-page HTML file that can be directly opened in a browser (three-column layout):
- Left Column: Problem statement + dynamic console — a variable parameter slider (such as line inclination angle θ / moving point parameter t) drives real-time recalculation of geometric quantities (intersection coordinates, slopes, dot products, chord lengths, areas…), along with a "theoretical range bar" or "fixed value indicator".
- Middle Column: Step-by-step explanations (formulas rendered with KaTeX), which can be collapsed with one click to make space for the drawing board.
- Right Column: 2D Canvas dynamic geometry drawing board (conic sections + moving lines/moving points + vectors + point annotations + grid coordinate axes), with an overlay brush doodling toolbar.
It has the same form as the target template .
/Users/wuyi/code/code2026/6/template/code_artifact.html依赖(重要)
Dependencies (Important)
计算核心 依赖 sympy。运行脚本前先确认有能 import sympy 的
解释器:(本机用 ,sympy 1.14)。
lib/analytic_kernel.pypython3 -c "import sympy"/opt/homebrew/bin/python3.11缺库时:若 import 报错(sympy 或后续任何库),先询问用户是否安装,同意后再装
()或换一个已装该库的解释器;不要未经询问直接装。
下文 均指这个能跑通依赖的解释器。
python3 -m pip install <库名>python3The calculation core depends on sympy. Before running the script, confirm you have an interpreter that can import sympy: (local environment uses , sympy 1.14).
lib/analytic_kernel.pypython3 -c "import sympy"/opt/homebrew/bin/python3.11When libraries are missing: If an import error occurs (sympy or any subsequent library), first ask the user for permission to install, then install it () or switch to an interpreter that already has the library installed; do not install without asking. The term below refers to this dependency-compatible interpreter.
python3 -m pip install <library name>python3工作流程
Workflow
第 1 步:得到 problem spec(三入口归一)
Step 1: Obtain problem spec (unify three entry points)
把题目整理成结构化 spec(曲线类型与参数、已知点/条件、所求类型与对象、语言)。
- 文字题:直接抽取。
- 图片:视觉读图抽取,并把识别到的题目回显给用户确认(题面/曲线/参数/所求/语言)再继续。
- 随机出题:选曲线 + 题型,随机参数 → kernel 求解,用 判答案 是否规整,不规整就重抽。
analytic_kernel.is_clean(...)
输出语言跟随提示词语言:英文提示 → 英文网页,中文 → 中文。spec 记下。language
Organize the problem into a structured spec (curve type and parameters, known points/conditions, target type and object, language).
- Text problems: Extract directly.
- Images: Extract via visual reading, and echo the recognized problem to the user for confirmation (problem statement/curve/parameters/target/language) before proceeding.
- Random problem generation: Select curve + problem type, generate random parameters → solve with kernel, use to check if the answer is neat, re-select parameters if not.
analytic_kernel.is_clean(...)
Output language follows prompt language: English prompts → English webpage, Chinese prompts → Chinese webpage. Recordin the spec.language
第 2 步:用 kernel 精确计算(不要心算)
Step 2: Perform precise calculations with kernel (do not calculate manually)
按 的解法配方,调用 与 :
references/conventions.mdlib/analytic_kernel.pylib/conics.py- 得曲线对象(精确 a,b,c、焦点、顶点、准线、 渐近线、
conics.ellipse/hyperbola/parabola/circle(...)、以及给前端引擎的eq_latexdict)。board - 联立含参直线
chord_setup(conic, through)得 y 的二次方程 + 韦达量(精确)。x=my+c - 目标量:/
dot_product_expr/chord_len_sq_expr/triangle_area_expr…slope_product_central - 取值范围:—— 含开闭端点判定(关键正确性点,见下)。
range_over_m(expr, horizontal_valid=?) - 定值:。
is_constant_in_m(expr)
可命令行自检 kernel:
bash
python3 lib/analytic_kernel.py # 旗舰题内置断言自检⚠️ 端点开闭 = 正确性命门:过焦点的弦,水平线(x 轴,θ=0)与竖直线(θ=90)都是合法直线, 它们取到的端点要计入。例:椭圆 MA·MB 题,x 轴取到 −3、竖直线取到 7/4,故答案是闭区间(很多教辅误写成开的[-3, 7/4])。(-3, 7/4]已据此判定,且这样答案与交互 工具一致——拖滑块到 0° 就读到 −3。抛物线焦点弦的"轴方向"是退化线(只交一点),其极限端点 不计入(range_over_m或限制 param 范围)。horizontal_valid=False
Follow the solution recipe in , call and :
references/conventions.mdlib/analytic_kernel.pylib/conics.py- to get curve objects (precise a,b,c, foci, vertices, directrices, asymptotes,
conics.ellipse/hyperbola/parabola/circle(...), andeq_latexdict for front-end engine).board - to set up simultaneous parametric line
chord_setup(conic, through)and obtain quadratic equation in y + Vieta quantities (precise).x=my+c - Target quantities: /
dot_product_expr/chord_len_sq_expr/triangle_area_expr…slope_product_central - Value ranges: — includes open/closed endpoint determination (key correctness point, see below).
range_over_m(expr, horizontal_valid=?) - Fixed values: .
is_constant_in_m(expr)
Self-check the kernel via command line:
bash
python3 lib/analytic_kernel.py # Built-in assertion self-check for flagship problems⚠️ Endpoint open/closed = correctness critical point: For chords passing through foci, horizontal lines (x-axis, θ=0) and vertical lines (θ=90) are valid lines, and their endpoints should be included. Example: For an ellipse MA·MB problem, the x-axis gives −3 and the vertical line gives 7/4, so the answer is the closed interval(many teaching materials incorrectly write it as the open interval[-3, 7/4]).(-3, 7/4]has already made this determination, and the answer is consistent with the interactive tool — drag the slider to 0° to read −3. The "axis direction" of a parabola's focal chord is a degenerate line (intersects at only one point), and its limit endpoints are not included (range_over_mor restrict param range).horizontal_valid=False
第 3 步:组装数据并注入模板
Step 3: Assemble data and inject into template
📍 输出位置 & 唯一产物(最重要):交付给用户的只有一个,写到当前工作目录 (.html)(除非用户显式指定路径)。cwd 里不要留任何别的文件——构建脚本(Path.cwd())、.py、自检截图(__pycache__)、临时文件都不是交付物,一律放.png或用完即删。 也绝不要写进技能自身目录(/tmp是技能内部样例)。skills/edu-analytic-geometry/output/
把"组装数据 + 注入模板"的构建脚本写到临时目录(如 ),让它只把
写到 cwd;脚本拼出 / / 数据(schema 见 ),
调用 注入 ,跑完即删脚本:
/tmp/ag_build.py.htmllessonstepsboardreferences/problem-schema.mdgenerate.render_html(data, out)template/board.htmlpython
undefined📍 Output Location & Unique Product (Most Important): The only deliverable to the user is a singlefile, written to the current working directory (.html) (unless the user explicitly specifies a path). Do not leave any other files in the cwd — build scripts (Path.cwd()),.py, self-check screenshots (__pycache__), temporary files are not deliverables; place them in.pngor delete them after use. Never write into the skill's own directory (/tmpis for internal skill samples).skills/edu-analytic-geometry/output/
Write the "assemble data + inject template" build script to a temporary directory (e.g., ), make it only write the file to cwd; the script constructs / / data (schema see ), calls to inject into , delete the script immediately after running:
/tmp/ag_build.py.htmllessonstepsboardreferences/problem-schema.mdgenerate.render_html(data, out)template/board.htmlpython
undefined构建脚本放 /tmp(不要放 cwd):/tmp/ag_build.py
Build script placed in /tmp (not cwd): /tmp/ag_build.py
import sys; sys.dont_write_bytecode = True # 不生成 pycache
sys.path.insert(0, "<技能目录>/scripts")
import generate
from pathlib import Path
data = {"lesson": {...}, "steps": [...], "board": {...}}
out = Path.cwd() / "solution-<题目简述>.html" # 唯一产物,落在用户当前目录
generate.render_html(data, out)
```bash
python3 -B /tmp/ag_build.py && rm -f /tmp/ag_build.py # -B 不写字节码;跑完删临时脚本,cwd 只剩 .html- 里的数值直接引用 kernel 结果(用
steps[*].content输出 LaTeX),模型只负责 组织讲解文字(按目标语言)。K.tex(...) - 用 kernel 给的曲线
boarddict、精确点坐标、board、param构造序列、derived、readouts(范围题)/rangeBar(定值题)/constant(形状参数题,如离心率范围)。answerBand - 形状参数题(滑块=离心率 e 等):自然动态量是曲线本身的形状而非动直线/动点时,让滑块=该参数,
把曲线 、焦点、动点坐标写成
a/b/c的表达式字符串(引擎每帧重绘曲线/焦点/渐近线), 配@param读数显示不等式状态、status在参数轴高亮答案区间。见 conventions「形状参数题」。answerBand - 可直接照抄的范本:里 6 个
scripts/generate.py覆盖各类交互范式:build_*(范围条)、ellipse_dot_range、ellipse_chord_range、ellipse_area_max(定值·中心对称)、ellipse_slopeprod_const(定值·抛物线)、parabola_dot_const(形状参数:滑块=e,曲线随之重绘 +hyperbola_ecc_range+status)。answerBand
已注册题直接出( 不写字节码;不传路径默认写技能 output,交付给用户时务必改成 cwd 下的 ):
-B.htmlbash
python3 -B scripts/generate.py list # 列出题型
python3 -B scripts/generate.py ellipse_dot_range ./sol.html
python3 -B scripts/generate.py all ./out_dir # 全部题型import sys; sys.dont_write_bytecode = True # Do not generate pycache
sys.path.insert(0, "<skill directory>/scripts")
import generate
from pathlib import Path
data = {"lesson": {...}, "steps": [...], "board": {...}}
out = Path.cwd() / "solution-<problem brief>.html" # Unique product, located in user's current directory
generate.render_html(data, out)
```bash
python3 -B /tmp/ag_build.py && rm -f /tmp/ag_build.py # -B does not write bytecode; delete temporary script after running, only .html remains in cwd- Numerical values in directly reference kernel results (use
steps[*].contentto output LaTeX), the model is only responsible for organizing explanatory text (in the target language).K.tex(...) - is constructed using the curve's
boarddict from kernel, precise point coordinates,board,paramsequences,derived,readouts(range problems)/rangeBar(fixed value problems)/constant(shape parameter problems, such as eccentricity ranges).answerBand - Shape parameter problems (slider = eccentricity e, etc.): When the natural dynamic quantity is the curve's own shape rather than moving lines/moving points, set the slider to this parameter, write the curve's , foci, moving point coordinates as expression strings with
a/b/c(the engine redraws the curve/foci/asymptotes every frame), match with@paramreading to display inequality status, andstatusto highlight the answer interval on the parameter axis. See conventions "Shape Parameter Problems".answerBand - Copyable templates: The 6 functions in
build_*cover various interaction paradigms:scripts/generate.py(range bar),ellipse_dot_range,ellipse_chord_range,ellipse_area_max(fixed value · central symmetry),ellipse_slopeprod_const(fixed value · parabola),parabola_dot_const(shape parameter: slider = e, curve redraws accordingly +hyperbola_ecc_range+status).answerBand
Generate registered problems directly ( does not write bytecode; default writes to skill output if no path is passed, must change to in cwd when delivering to users):
-B.htmlbash
python3 -B scripts/generate.py list # List problem types
python3 -B scripts/generate.py ellipse_dot_range ./sol.html
python3 -B scripts/generate.py all ./out_dir # All problem types第 4 步:自检(正确性方案)
Step 4: Self-check (Correctness Plan)
- kernel 答案 == 答案卡 == 末步骤展示值 == JS 标准位/扫段重算值,四者一致 (
lesson.answer内已加build_*)。assert - 端点来自 kernel 的
rangeBar;range_over_m值来自 kernel 的定值。constant - 起本地静态服务(服务输出文件所在目录,即 cwd)用预览检查:无控制台报错、KaTeX 正常、
滑块实时重算正确、范围条/定值/定点/轨迹行为符合、画笔与收起面板可用。
(技能仓库内开发时可用 的
.claude/launch.json,端口 4601;别处运行就对 cwd 起 一个临时静态服务。)ag-preview - 自检截图只给你自己看:preview 工具直接返回图像,不要把 存到 cwd;本地静态服务只读不写、 不产生文件。自检产生的任何临时文件(构建脚本
.png、截图.py、.png等)交付前一律清掉。__pycache__
⚠️ 必须关闭你开过的端口/服务:预览一结束立即停掉,绝不留占用端口的进程。
- preview 工具开的:
(传 serverId)。preview_stop- 直接起的
:用完http.server,或kill确认已释放。lsof -nP -iTCP:<port> -sTCP:LISTEN- 交付前确认端口已释放再告诉用户。开了不关 = 未完成自检。
- Kernel answer == answer card == final step display value == JS standard bit/segment scan recalculation value, all four are consistent (
lesson.answerhas been added inassert).build_* - endpoints come from kernel's
rangeBar;range_over_mvalue comes from kernel's fixed value.constant - Start a local static server (serving the directory where the output file is located, i.e., cwd) to preview and check: no console errors, KaTeX renders normally, slider recalculates in real-time correctly, range bar/fixed value/fixed point/locus behavior is correct, brush and panel collapse are usable.
(When developing in the skill repository, use in
ag-preview, port 4601; when running elsewhere, start a temporary static server for cwd.).claude/launch.json - Self-check screenshots are for your own viewing only: The preview tool returns images directly, do not save to cwd; the local static server is read-only, no files are generated. Delete any temporary files generated during self-check (build scripts
.png, screenshots.py,.png, etc.) before delivery.__pycache__
⚠️ Must close any ports/services you opened: Stop the server immediately after preview, never leave port-occupying processes running.
- Opened by preview tool:
(pass serverId).preview_stop- Directly started
: Usehttp.serverafter use, orkillto confirm release.lsof -nP -iTCP:<port> -sTCP:LISTEN- Confirm ports are released before notifying the user. Not closing ports = incomplete self-check.
第 5 步:交付
Step 5: Delivery
成品写在用户当前工作目录(cwd),命名形如 ,把路径告诉用户,
可直接浏览器打开。交付前确认:(1) 成品在 cwd、不在技能目录;(2) 没有遗留本次预览
开启的本地服务/端口;(3) cwd 里只新增了这一个 ——没有 / /
/ 临时文件(用 或 核一眼,有就删掉)。
solution-<题目简述>.html.html.py.png__pycache__git statuslsThe finished product is written to the user's current working directory (cwd), named like . Inform the user of the path, which can be directly opened in a browser. Before delivery, confirm: (1) The finished product is in cwd, not in the skill directory; (2) No local services/ports opened during this preview are left running; (3) Only this single file is newly added in cwd — no / / / temporary files (check with or , delete if any).
solution-<problem brief>.html.html.py.png__pycache__git statusls扩展
Expansion
- 加题型:在 加目标量函数(写成 m 的表达式)+ 复用
analytic_kernel.py/range_over_m;在is_constant_in_m加一个generate.py,选定交互范式(范围条 / 定值 / 定点 / 轨迹 trace / 形状参数 answerBand)。见build_*配方表。references/conventions.md - 加曲线:已有椭圆/双曲线/抛物线/圆;前端
conics.py引擎已支持四类渲染、 渐近线、准线方向。新曲线在两处各加一份即可。board.html - 加交互构造:的
board.htmlswitch 是构造库(buildScene、line_through_angle、intersect_line_conic、point_on_conic、point_reflect、tangent_at…), 按需扩充并在 schema 文档登记。foot_perp
- Add problem types: Add target quantity functions (written as expressions of m) in + reuse
analytic_kernel.py/range_over_m; add ais_constant_in_mfunction inbuild_*, select an interaction paradigm (range bar / fixed value / fixed point / locus trace / shape parameter answerBand). See the recipe table ingenerate.py.references/conventions.md - Add curves: already has ellipse/hyperbola/parabola/circle; the front-end
conics.pyengine already supports rendering of four types, asymptotes, and directrix directions. Just add new curves in both places.board.html - Add interactive constructions: The switch in
buildSceneis a construction library (board.html,line_through_angle,intersect_line_conic,point_on_conic,point_reflect,tangent_at…), expand as needed and register in the schema document.foot_perp
目录
Directory
- — 数据驱动模板(通用 2D 渲染器 + 参数引擎 + 数据岛
template/board.html)__LESSON_DATA__ - — 圆锥曲线 sympy 定义库(特殊点 / LaTeX / board dict)
lib/conics.py - — sympy 精确求解核心(联立·韦达·范围·定值)
lib/analytic_kernel.py - — 注入模板 + 5 个 build_* 范本 + 批量/单题出题
scripts/generate.py - — 数据格式(board 引擎 schema)
references/problem-schema.md - — 标准式、解法配方表、韦达/换元套路、端点开闭、自检
references/conventions.md
- — Data-driven template (universal 2D renderer + parameter engine + data island
template/board.html)__LESSON_DATA__ - — sympy definition library for conic sections (special points / LaTeX / board dict)
lib/conics.py - — sympy precise calculation core (simultaneous equations · Vieta's formulas · ranges · fixed values)
lib/analytic_kernel.py - — Template injection + 5 build_* templates + batch/single problem generation
scripts/generate.py - — Data format (board engine schema)
references/problem-schema.md - — Standard forms, solution recipes, Vieta/substitution routines, endpoint open/closed rules, self-check
references/conventions.md