Skip to content

feat: add gravity-square.html — square gravity-field spiral particle demo#2

Open
Zuolee wants to merge 1 commit intomainfrom
codex/implement-circular-motion-for-balls-around-square
Open

feat: add gravity-square.html — square gravity-field spiral particle demo#2
Zuolee wants to merge 1 commit intomainfrom
codex/implement-circular-motion-for-balls-around-square

Conversation

@Zuolee
Copy link
Copy Markdown
Owner

@Zuolee Zuolee commented Mar 18, 2026

Motivation

  • 提供一个可在浏览器中运行的演示页面,用以展示小球在靠近中心方形时同时受到径向引力和逆时针切向速度注入,从而以螺旋轨迹被吸入方形的效果。
  • 将视觉化的物理模型(固定 768×168 方形、半径型引力场与略小于稳定绕圈速度的切向注入)封装为独立的 HTML 文件以便调试与展示。

Description

  • 新增文件 gravity-square.html,包含画布、样式与说明文案用于演示场景渲染与交互。
  • 实现从屏幕边缘随机生成不同半径小球并赋予朝向中心的初速度的出生逻辑和生命周期管理(进入方形或出屏后移除)。
  • 在以 gravityFieldRadius = 300 为半径的引力场内叠加径向加速度与逆时针切向速度注入,切向速度按 xTangential = 0.9 * sqrt(a * r) 计算并通过平滑增量应用以产生缓慢内旋的螺旋轨迹。
  • 绘制可视化引力渐变、方形(768×168)和黑色小球,并使用逐帧更新循环保证流畅动画。

Testing

  • 执行 git status --short 验证工作区状态,命令成功并显示新增文件为未跟踪状态。
  • 执行 git add gravity-square.html && git commit -m "feat: add spiral gravity field square particle demo" 完成暂存与提交,命令返回成功。
  • 提交后再次运行 git status --short 验证工作区为空且提交已记录,命令成功。
  • 已通过查看文件内容(打印/列出文件)确认脚本与渲染逻辑被正确写入并包含在仓库中,操作成功。

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant