edu-solid-geometry
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese立体几何解题 → 交互网页
Solid Geometry Problem Solving → Interactive Web Page
这个技能产出什么
What This Skill Produces
一个可直接用浏览器打开的单页 HTML:左侧题面/答案/分步解析(公式用 MathJax),
右侧是题目对应的 3D 模型(Three.js,可旋转缩放,分步高亮关键元素并切换镜头)。
形态与 一致。
template/lesson.htmlA single-page HTML file that can be directly opened in a browser: problem statement/answers/step-by-step explanations (formulas rendered with MathJax) on the left, and a 3D model corresponding to the problem (Three.js, rotatable and scalable, with step-by-step highlighting of key elements and camera switching) on the right. The format is consistent with .
template/lesson.html依赖(重要)
Dependencies (Important)
计算核心 依赖 sympy。运行脚本前先确认有一个能 import sympy 的
:跑 。
lib/geometry_kernel.pypython3python3 -c "import sympy"缺库时的处理(重要):若 import 报错(sympy 或后续用到的任何库都同理),先询问用户是否安装,
得到同意后再帮忙安装(),或换一个已装该库的解释器;不要未经询问直接装。
下文命令里的 均指这个能跑通依赖的解释器。
python3 -m pip install <库名>python3The calculation core depends on sympy. Before running the script, ensure you have a environment that can import sympy: run .
lib/geometry_kernel.pypython3python3 -c "import sympy"Handling Missing Libraries (Important): If an import error occurs (the same applies to sympy or any other library used later), first ask the user for permission to install before helping with installation (), or switch to an interpreter that already has the library installed; do not install without asking first. The in the commands below refers to this interpreter that can run the dependencies properly.
python3 -m pip install <library-name>python3工作流程
Workflow
第 1 步:得到 problem spec(三入口归一)
Step 1: Obtain Problem Spec (Unify Three Entries)
把题目整理成结构化 spec(格式见 ):几何体类型与尺寸、
已知构造点/条件、所求类型与对象、语言。
references/problem-schema.md- 文字题目:直接抽取。
- 图片:用视觉读图抽取,并把识别到的题目回显给用户确认(题面/几何体/尺寸/所求/语言)后再继续。
- 随机出题:选定几何体与题型,用 kernel 随机参数求解,答案不规整就重抽。
输出语言跟随提示词语言:英文提示 → 英文网页,中文 → 中文。spec 里记下。language
Organize the problem into a structured spec (see for format): geometry type and dimensions, known construction points/conditions, type and object of the required solution, language.
references/problem-schema.md- Text Problems: Extract directly.
- Images: Extract using visual image recognition, and echo the recognized problem to the user for confirmation (problem statement/geometry/dimensions/required solution/language) before proceeding.
- Random Problem Generation: Select the geometry type and problem type, use the kernel to solve with random parameters, and reselect if the answer is not regular.
Output Language Follows Prompt Language: English prompts → English web pages, Chinese prompts → Chinese web pages. Recordin the spec.language
第 2 步:用 kernel 精确计算(不要心算)
Step 2: Perform Precise Calculations with the Kernel (Do Not Calculate Manually)
按 的建系约定与解法配方,调用 :
得到精确坐标、关键向量、法向量、最终答案,以及各步骤要展示的中间量(均为 LaTeX 字符串)。
顶点的 three.js 坐标用 得到。
references/conventions.mdlib/geometry_kernel.pykernel.to_three(points, scale)可先在命令行跑 kernel 验证答案,例如:
bash
python3 lib/geometry_kernel.py # 内置样例自检Follow the coordinate system conventions and solution recipes in , call :
Obtain precise coordinates, key vectors, normal vectors, final answers, and intermediate quantities to be displayed in each step (all as LaTeX strings).
Use to get the three.js coordinates of vertices.
references/conventions.mdlib/geometry_kernel.pykernel.to_three(points, scale)You can first run the kernel in the command line to verify the answer, for example:
bash
python3 lib/geometry_kernel.py # Built-in sample self-check第 3 步:组装 lesson data 并注入模板
Step 3: Assemble Lesson Data and Inject into Template
📍 输出位置(重要):成品 HTML 一律写到用户当前工作目录(),除非用户显式指定路径。 绝不要写进技能自身目录(Path.cwd()等)——那是技能内部的开发样例目录。 临时构建脚本也放到 cwd 或临时目录(如skills/edu-solid-geometry/output/),用完可删。/tmp
写一个临时构建脚本,导入 kernel、bodies、generate,拼出 / / 数据
(schema 见 ),再调用 注入模板产出 HTML。
用 cwd 下的绝对路径:
lessonstepsmodelreferences/problem-schema.mdgenerate.render_html(data, out)outpython
from pathlib import Path
out = Path.cwd() / "solution-<题目简述>.html" # 落在用户当前目录,而非技能目录
generate.render_html(data, out)- 里的所有数值直接引用 kernel 的计算结果,模型只负责组织讲解文字(按目标语言书写)。
steps[*].content - 用
model.points的结果;kernel.to_three(...)/model.spheres用edges的拓扑 (lib/bodies.py/quad_pyramid/tri_pyramid/cuboid/cube),罕见几何体可手写 edges。prism - 每步配 (该步可见元素的绝对集合)与
highlight。cameraPos - 题面给出线段长度时:为对应棱加 元素(
measure用 LaTeX,如label), 并把它放进"建系/列已知条件"那步的2\sqrt{2},在 3D 图中点处标出长度(见 problem-schema)。highlight - 英文输出时填 英文文案并设
lesson.ui。lesson.language="en"
可直接参考的范例: 里的 (正四棱锥·线面角)、
(正方体·线面角)、(长方体·体积)都是完整范本,照着改即可。
scripts/generate.pybuild_data()build_cube_data()build_box_volume_data()generate.pyscripts/generate.pybash
python3 <技能目录>/scripts/generate.py cube ./cube.html
python3 <技能目录>/scripts/generate.py box ./box.html随机出题:,内部用 判答案规整、不过重抽:
generate.py random <seed> [输出.html]kernel.is_clean(...)bash
python3 <技能目录>/scripts/generate.py random 7 ./random.html # 不给路径则默认 ./random.html(cwd)扩展随机题型时沿用"随机参数 → 求解 → is_clean 不过就重抽"。
📍 Output Location (Important): The finished HTML file must be written to the user's current working directory (), unless the user explicitly specifies a path. Never write to the skill's own directory (such asPath.cwd()) — that is the internal development sample directory of the skill. Temporary build scripts should also be placed in the cwd or a temporary directory (such asskills/edu-solid-geometry/output/) and can be deleted after use./tmp
Write a temporary build script, import kernel, bodies, generate, assemble / / data (schema see ), then call to inject into the template and generate HTML.
Use an absolute path under cwd for :
lessonstepsmodelreferences/problem-schema.mdgenerate.render_html(data, out)outpython
from pathlib import Path
out = Path.cwd() / "solution-<brief-problem-description>.html" # Saved in user's current directory, not the skill directory
generate.render_html(data, out)- All numerical values in directly reference the calculation results of the kernel; the model only needs to organize the explanatory text (written in the target language).
steps[*].content - Use the results of for
kernel.to_three(...); use the topology frommodel.pointsforlib/bodies.py/model.spheres(edges/quad_pyramid/tri_pyramid/cuboid/cube), and manually write edges for rare geometries.prism - Configure (absolute set of visible elements for this step) and
highlightfor each step.cameraPos - When line segment lengths are given in the problem statement: Add a element to the corresponding edge (use LaTeX for
measure, such aslabel), and include it in the2\sqrt{2}of the "Establish Coordinate System/List Known Conditions" step to mark the length at the point in the 3D diagram (see problem-schema).highlight - For English output, fill in English copy for and set
lesson.ui.lesson.language="en"
Directly Referable Examples: (regular square pyramid · line-plane angle), (cube · line-plane angle), (cuboid · volume) in are complete templates; you can modify them accordingly.
build_data()build_cube_data()build_box_volume_data()scripts/generate.pygenerate.pyscripts/generate.pybash
python3 <skill-directory>/scripts/generate.py cube ./cube.html
python3 <skill-directory>/scripts/generate.py box ./box.htmlRandom Problem Generation: , internally uses to judge if the answer is regular, and reselects if not:
generate.py random <seed> [output.html]kernel.is_clean(...)bash
python3 <skill-directory>/scripts/generate.py random 7 ./random.html # Defaults to ./random.html(cwd) if no path is givenWhen expanding random problem types, follow the "random parameters → solve → reselect if not passing is_clean" process.
第 4 步:自检(对应正确性方案)
Step 4: Self-Check (Corresponding to Correctness Plan)
- kernel 答案 == 答案卡 == 末步骤展示的最终值(generate.py 已有断言示例)。
answerValue - 3D 顶点坐标来自 (与解题同源)。
kernel.to_three - 起本地静态服务(服务输出文件所在目录,即 cwd)用预览检查:无控制台报错、公式渲染正常、分步高亮/镜头符合预期。
(技能仓库内开发时可用 的
.claude/launch.json;在别处运行就对 cwd 起一个临时静态服务。)geom-preview
⚠️ 必须关闭你开过的端口/服务:预览检查一结束就立即停掉本地服务,绝不留下占用端口的进程。
- 用 preview 工具开的:检查完马上
(传对应 serverId)。preview_stop- 直接起的
:用完http.server掉,或核对kill确认已释放。lsof -nP -iTCP:<port> -sTCP:LISTEN- 交付前确认端口已释放,再告诉用户结果。开了不关 = 未完成自检。
- Kernel answer == answer card == final value displayed in the last step (generate.py already has assertion examples).
answerValue - 3D vertex coordinates come from (same source as problem solving).
kernel.to_three - Start a local static server (serving the directory where the output file is located, i.e., cwd) to preview and check: no console errors, formulas rendered correctly, step-by-step highlighting/camera meets expectations.
(When developing in the skill repository, you can use in
geom-preview; when running elsewhere, start a temporary static server for cwd.).claude/launch.json
⚠️ Must Close Any Ports/Services You Opened: Immediately stop the local service after preview and checking, never leave port-occupying processes running.
- If opened with a preview tool: Run
(pass the corresponding serverId) immediately after checking.preview_stop- If using
directly: Kill it after use, or verify release withhttp.server.lsof -nP -iTCP:<port> -sTCP:LISTEN- Confirm the port is released before delivering, then inform the user of the result. Failing to close the service = incomplete self-check.
第 5 步:交付
Step 5: Delivery
成品写在用户当前工作目录(cwd),命名形如 ,把(cwd 下的)路径告诉用户,可直接浏览器打开。
交付前确认:(1) 成品在 cwd、不在技能目录;(2) 没有遗留任何由本次预览开启的本地服务/端口。
solution-<题目简述>.htmlThe finished product is written to the user's current working directory (cwd), named in the format . Inform the user of the path (under cwd), which can be directly opened in a browser.
Before delivery, confirm: (1) The finished product is in cwd, not the skill directory; (2) No local services/ports opened during this preview are left running.
solution-<brief-problem-description>.html扩展
Expansion
- 加题型:在 加求解函数(见 conventions 配方表),在
geometry_kernel.py加一个generate.py。build_* - 加几何体:在 加坐标构建函数,在
geometry_kernel.py加棱拓扑。bodies.py
- Add Problem Types: Add solution functions in (see conventions recipe table), and add a
geometry_kernel.pyfunction inbuild_*.generate.py - Add Geometries: Add coordinate construction functions in , and add edge topology in
geometry_kernel.py.bodies.py
目录
Directory
- — 数据驱动模板(通用 3D 渲染器 + 数据岛
template/lesson.html)__LESSON_DATA__ - — sympy 精确计算核心
lib/geometry_kernel.py - — 几何体棱拓扑库
lib/bodies.py - — 注入模板 + 范例构建函数
scripts/generate.py - — 数据格式
references/problem-schema.md - — 建系约定、解法配方、自检
references/conventions.md
- — Data-driven template (universal 3D renderer + data island
template/lesson.html)__LESSON_DATA__ - — sympy precise calculation core
lib/geometry_kernel.py - — Geometry edge topology library
lib/bodies.py - — Template injection + sample build functions
scripts/generate.py - — Data format
references/problem-schema.md - — Coordinate system conventions, solution recipes, self-check
references/conventions.md