Skip to content

feat: add 1D collision simulation with vector visualization#317

Merged
mattqdev merged 2 commits into
physicshub:mainfrom
AgnibhaDebnath:feature/collision-simulation
May 16, 2026
Merged

feat: add 1D collision simulation with vector visualization#317
mattqdev merged 2 commits into
physicshub:mainfrom
AgnibhaDebnath:feature/collision-simulation

Conversation

@AgnibhaDebnath
Copy link
Copy Markdown
Contributor

🔍 Description

Added a new 1D collision simulation with adjustable mass, velocity, and restitution.

The simulation includes:

  • Velocity vector visualization
  • Momentum and kinetic energy calculations
  • Boundary collision handling
  • Trail rendering support
  • Responsive layout support

This simulation was designed to help students better understand conservation of momentum and elastic collisions through interactive visualization.

Closes #180


✅ Checklist

  • Verified that the project builds and runs locally (npm run dev)
  • Ensured no ESLint or TypeScript warnings/errors remain
  • Updated documentation, comments, or in-code explanations where needed
  • Verified responsiveness across devices (desktop, tablet, mobile)
  • Followed the CONTRIBUTING.md guidelines

🎨 Visual Changes

Collision_simulation.mp4
  • Ball collisions
  • Velocity vectors
  • Momentum and kinetic energy updates
  • Trail rendering

📂 Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📝 Documentation update
  • ♻️ Refactor / code quality improvement
  • 🎨 UI/UX enhancement
  • 🔒 Security improvement

🧩 Additional Notes for Reviewers

  • Uses reusable PhysicsBody and ForceRenderer systems already present in the project
  • Includes overlap correction for more stable collision response
  • Supports responsive resizing for smaller screens
  • Future improvements may include extending the simulation to support 2D collisions.

@mattqdev
Copy link
Copy Markdown
Collaborator

Hey @AgnibhaDebnath well done, it seems good, so i'm going to merge it! I meant originally a simulation with 2d collision (a better version of benchmark one), but this is fine also!
thank you again for this!

@mattqdev mattqdev merged commit 180d02c into physicshub:main May 16, 2026
1 check passed
@AgnibhaDebnath
Copy link
Copy Markdown
Contributor Author

AgnibhaDebnath commented May 16, 2026

Thank you @mattqdev! I’m glad the implementation was helpful. I’d also be interested in exploring a 2D collision version in the future.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: New simulation for ball collisions

2 participants