Command Palette

Search for a command to run...

Назад к скиллам
скилл № 66971

dev-physics-lesson

Add a physics lesson — particle dynamics, rigid bodies, collisions, constraints, rendered with SDL GPU

БесплатноБез исполняемых скриптов
Nebulavenusот Nebulavenus★ 51 звезда на GitHub

Установить dev-physics-lesson в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Every physics lesson produces two things: library code and a demo program. The library — common/physics/forge_physics.h — is the crown jewel. The lessons teach concepts; the library is what remains when the learning is done. It must be thorough, correct, performant, tested, safe, and valid. The demo program visualizes the library in action, rendered in real time with SDL GPU.

When to use this skill:

  • You need to teach particle dynamics, rigid body physics, or collision detection
  • A learner wants to understand integration, forces, impulses, or constraints
  • The concept benefits from a live 3D visualization showing behavior over time
  • New functionality needs to be added to common/physics/forge_physics.h

Smart behavior:

  • Before creating a lesson, check if an existing physics lesson already covers it
  • Library first, demo second. Design, implement, document, and test the library code before writing a single line of the demo program. The demo exercises the library — it does not replace it.
  • Physics lessons are visual — every concept must be observable in the running program
  • Focus on why the math works, not just the code — connect equations to behavior
  • Use simple geometric shapes (cubes, spheres, capsules) — the physics is the star
  • All scene geometry comes from common/shapes/forge_shapes.h — never write inline geometry generation functions
  • Cross-reference math lessons (vectors, matrices, quaternions) and GPU lessons where relevant

Arguments

The user (or you) can provide:

  • Number: two-digit lesson number (e.g. 01, 02)
  • Topic name: kebab-case (e.g. point-particles, springs-and-constraints)
  • Description: what this teaches (e.g. "Symplectic Euler integration, gravity, drag")

If any are missing, infer from context or ask.

Steps

1. Analyze what's needed

  • Check existing physics lessons: Is there already a lesson for this topic?
  • Check common/physics/: Does relevant library code already exist?
  • Check common/shapes/forge_shapes.h: Does the shapes library already provide every shape the lesson needs? If a required shape is missing, plan to add it to forge_shapes.h (not inline in the lesson).
  • Identify the scope: What specific physics concepts does this lesson cover?
  • Find cross-references: Which math/GPU lessons relate?
  • Check PLAN.md: Where does this lesson fit in the physics track?

2. Create the lesson directory

lessons/physics/NN-topic-name/

With subdirectories:

lessons/physics/NN-topic-name/
  main.c
  CMakeLists.txt
  README.md
  assets/

Baseline rendering shaders (shadow, scene, grid, sky, UI) are provided by forge_scene.h — no per-lesson copies needed. If the lesson introduces a topic-specific shader (e.g. a debug visualization pass), add a shaders/ subdirectory for those files only.

3. Design and implement the physics library code

Every physics lesson adds to common/physics/forge_physics.h. This is not optional — it is the primary deliverable. The demo program exists to exercise and visualize the library; the library is what ships.

For the first physics lesson, create the file. For subsequent lessons, extend it. Design the API before writing the demo. The demo calls the library — never the reverse.

Library standards

These standards are non-negotiable. The physics library is safety-critical code — incorrect integration, missed edge cases, or division by zero produce simulations that explode, tunnel through geometry, or silently drift. Every function must be defensible.

Correctness:

  • Every function must implement a named, well-understood algorithm (symplectic Euler, Verlet, GJK, sequential impulse). Cite the source in the doc comment — a textbook, paper, or established reference.
  • Equations in the README must correspond exactly to the code. If the README shows $v(t + \Delta t) = v(t) + a \cdot \Delta t$, the code must compute that expression in that order. No silent rearrangements.
  • Collision detection must handle degenerate cases: zero-length normals, coincident positions, zero-radius shapes, zero-mass bodies. Document what each function does when given degenerate input.
  • Integration must preserve physical invariants where the algorithm guarantees it. Symplectic Euler preserves phase-space volume — verify this in tests by checking energy over long runs.

Numerical safety:

  • Never divide without checking the denominator. Guard 1.0f / mass with an inv_mass field precomputed at construction, where mass == 0 means infinite mass (static object) and inv_mass == 0.
  • Normalize vectors only after checking length > epsilon. Use vec3_length() and compare against 1e-6f before calling vec3_normalize().
  • Clamp values that have physical bounds: restitution to [0, 1], damping to [0, 1], penetration depth to >= 0. Document the valid range in the parameter comment.
  • Use SDL_fabsf() for float comparisons, n
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл dev-physics-lesson?

Add a physics lesson — particle dynamics, rigid bodies, collisions, constraints, rendered with SDL GPU

Как установить скилл dev-physics-lesson?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл dev-physics-lesson запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить dev-physics-lesson с