Skip to main content

Questions tagged [physics]

Physics is a science that studies the interactions of energy and matter. The physics tag should be used for questions about how physics can be simulated or implemented in programming.

126 votes
4 answers
24k views

Celebratory fireworks animation

To celebrate an important event, I hastily cobbled together an HTML canvas-based animation. A few concerns I have include: Performance: Does it run reasonably smoothly on most modern machines? How ...
200_success's user avatar
33 votes
9 answers
8k views

Simple n-body class in C++

As part of my training, I implemented a n-body class in C++ to simulate gravitational interaction of bodies and to get more familiar with features that C++ offers such as object oriented programming. ...
Gilfoyle's user avatar
  • 1,125
32 votes
7 answers
7k views

Car crash reaction time

In physics class we are doing an investigation thing. Some of the numbers might seem plucked out of thin air but they aren't. The maths is right(I think) I just want some feedback on the code. ...
Danny's user avatar
  • 321
21 votes
2 answers
7k views

Barnes-Hut N-body simulator

I have written an n-body simulator, implementing the Barnes-Hut algorithm. Please comment on anything you can see wrong with this. Wikipedia Barnes-Hut page This is a screen shot of the simulation 20 ...
Kieren Pearson's user avatar
20 votes
3 answers
4k views

Planetary simulation in python

I have created a program in python that calculates forces between bodies (i.e earth, moon and a hypothetical moon) and make them move according to the changes in velocity and forces. This is the code ...
Hale's user avatar
  • 303
20 votes
1 answer
3k views

Asteroids game clone

I have recently been teaching a JavaScript module on a games programming undergraduate course and I made this game as a learning exercise and as an example for my students to study. I have made games ...
Graeme Stuart's user avatar
19 votes
4 answers
470 views

Ising Model - Atom Vibration Simulation in Scala

I am an experienced Java developer (12+ years) and have recently switched to Scala and I love it. However I feel not comfy yet and I have a feeling that I might use to many paradigms from the good old ...
Julian Pieles's user avatar
18 votes
3 answers
4k views

Simulating a two-body collision problem to find digits of Pi

I came across a nice video on 3Blue1Brown's channel that highlights a very indirect way to find the digits in Pi. I'd suggest watching the whole video, but briefly: The setup is as above. A "small" ...
Shirish's user avatar
  • 283
18 votes
1 answer
1k views

Fluid Simulation with SDL

I have always wanted to write a fluid simulation, and with the help of a paper and some StackOverflow users I've got something that works. My goal is to have a program that someone can run right away ...
qwr's user avatar
  • 1,084
17 votes
6 answers
6k views

Vector (physics) implementation

I recently started learning Java, and I decided to implement a basic vector system for another particle system I was building. ...
Ethan Bierlein's user avatar
17 votes
3 answers
280 views

"Do I understand the gravity of the situation?"

What is this? This is a two-dimensional physics simulator that models gravity and collisions between circular objects (though it doesn't model rotation). How do you use it? You can tweak the following ...
Thriggle's user avatar
  • 1,318
17 votes
1 answer
4k views

Bouncing stacking boxes

I'm not sure if it would be better to make the envelope into an extension of the Rectangle constructor. The physics seem a bit dodgy, it works well most of the time, but sometimes the boxes overlap ...
Tom's user avatar
  • 431
15 votes
3 answers
1k views

Simulating gravitational attraction between bodies

I'm currently working on a simple simulator in Unity3D that involves planets orbiting each other. I wrote the following C# script to do that. It uses the classic gravitational formula, $$F=G\frac{...
Ethan Bierlein's user avatar
15 votes
3 answers
5k views

Orbital Trajectory simulator

I have written a simple program to do trajectory simulation in the Earth-Moon system, it still has a long way to go I am working on making it more class oriented and am looking into implementing a ...
Mark Omo's user avatar
  • 449
13 votes
4 answers
572 views

Lines, intersections and terrible unit tests

I needed Line and LineF for the next stage of a project I'm working on, so I developed them. I also needed to determine if two ...
Der Kommissar's user avatar

15 30 50 per page
1
2 3 4 5
11