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.
7
votes
0answers
67 views
2D colliding disks in JavaScript (ideal billiard balls)
I am implementing a simulation of colliding disks (ideal 2D billiard balls) in JavaScript.
I follow an event-driven algorithm that avoids discretizing time; the algorithm goes as follows at each ...
0
votes
1answer
45 views
Calculating an object's stopping distance
I'm trying to smooth the movement of a cursor which has a set acceleration and max speed. I wrote this function to calculate the stopping distance of an object given its speed and acceleration, and it ...
3
votes
1answer
54 views
Explosion animation plugin for a game
I have been writing a small particle plugin since I want to learn how physics works for games. Now I have tried to get this as clean as I possible could but It feels something is missing. Am I ...
2
votes
0answers
13 views
2-body gravitation simulator
I've written a very simple 2-body gravitation simulator in MATLAB, but I think I've done something wrong with the physics, particularly where I define velocity as each frame is drawn.
...
4
votes
2answers
59 views
1D shock tube problem written in Fortran
I have written a simple Euler solver for the 1D shock tube problem. Eventually, I plan to extend this code to solve the full 3D compressible Navier-Stokes equations. Therefore, I want to start with ...
12
votes
2answers
384 views
Gravitational Brute Force N-body Algorithm
I've just started dabbling with code, and as a learning exercise I've written a simple algorithm for solving gravitational n-body problems numerically in JavaScript.
I would be very grateful for ...
3
votes
3answers
69 views
Creating and manipulating FITS files
I wrote a program that manipulated data from VLA observations and created FITS files to be used in creating spectral energy distributions of high redshift radio galaxies. I really tried to be as ...
6
votes
1answer
112 views
Java snow animation
I was inspired by this to write a graphic snow animation in Java/Processing. It works great, but it has some design issues.
The full project is here on github;
...
5
votes
1answer
55 views
Visual solution of the Newtonial differential equation with Python
I wrote this Python code that plots the movement of an object under the effect of a given force function in 2D by solving the Newton's movement equation numerically. One can add other force functions, ...
2
votes
1answer
48 views
Velocity verlet implementation
My code is meant to update the positions and velocities of planets. There are a few methods in this class, but updatePosition and ...
5
votes
0answers
101 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 ...
7
votes
3answers
66 views
Solving for every variable in a number of physics formulas
I'm working on making an iOS app to solve physics problems and I'm starting by just having it solve basic kinematics problems with the following formulas (I've coded it in C instead of Swift to start ...
11
votes
1answer
113 views
Basketball Collisions with Box2d
I'm working on a new prototype that is a simple drag and shoot arcade basketball game. For this project I am working with LibGDX and the Box2d physics library.
You can play the game here: Play ...
8
votes
2answers
310 views
Solar System model
I have a model that works, as far as I know, but it's so messy! I am very new to Java, so I'd really appreciate some help tidying up. In particular, a lot of my constructors are empty which is ...
14
votes
3answers
325 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 ...
14
votes
4answers
238 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 ...
6
votes
2answers
87 views
Simulating gravitational attraction between bodies - follow up
I've decided to revisit a chunk of code I wrote a while back, and see what I could do to make some changes. As a result, I know have slow, but working piece of code which is able to simulate ...
3
votes
1answer
43 views
Evolutionary algorithm to optimize the range of a glider
I created an evolutionary algorithm that optimises the range of a "glider"...ignore the accuracy of the physics behind the problem!
Any comments on how to improve the algorithm/my coding style would ...
4
votes
2answers
57 views
Python object-oriented pipe cooling simulations
Here is my code simulating liquid in a pipe cooling under different conditions. How did I do approaching this in an object orientated way? Is there any way I can improve this code?
...
6
votes
3answers
91 views
Python differential analysis of heat loss across a pipe
I made a differential equation solver to forecast heat loss through a pipe with heat loss coefficient contours. It does what I want it to do but I had to use global variables to change the outputs of ...
6
votes
1answer
37 views
Module for isotopic masses and abundances
I have written a small module for accessing data on isotope masses and relative abundances. My long term aim is to build tools in Haskell for working with mass spectrometry data. Any comments on how ...
3
votes
2answers
64 views
Program based on a physics concept
I am a beginner and I wanted to make programs that would help me while I learnt Java. I made a program to help me in my assignments. Any suggetions?
Main method
...
8
votes
2answers
170 views
Roll-a-ball controller
I've been toying around with Unity 5 lately, and in an effort to start making an actual game, I've built a ball controller similar to the one found in the Unity tutorial Roll-a-ball.
In essence, the ...
6
votes
1answer
187 views
Kinematic Equations Calculator
The program allows user to enter values for 3 of the following
initial velocity
final velocity
acceleration
displacement
time
and to specify an unknown (one of the previously mentioned ...
6
votes
4answers
572 views
Artillery game C++ practice project
I've completed a program as a learning experience to make sure I've got the concepts down. I found a practice project online and decided to try it out. The program compiles and runs exactly how it ...
7
votes
1answer
73 views
Animating a 2D particle “web”
I have written a small class to generate and animate one of those trendy particle webs. I plan to use this as the main background of my personal website, so naturally I'm concerned about the ...
4
votes
2answers
62 views
Generating Position
I'm written the following code to calculate the position of a motor during each timestep, the result of which will be compared with feedback from a quadrature encoder and subjected to a PID algorithm. ...
4
votes
2answers
68 views
2D physics game engine
I'm writing a 2D game engine, and I just wrote the physics for it to handle collisions between AABBs and circles.
It's on GitHub.
Some of my worries are that my code isn't OOP, because I have to do ...
8
votes
2answers
86 views
Particle swarm optimization - follow-up
This is a followup post to Particle Swarm Optimization.
I wrote a script in Python for particle swarm optimization and I posted it here to get comments on the design. I was told that encapsulating ...
15
votes
3answers
356 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,
...
6
votes
1answer
100 views
N-body sim with Barnes-Hut - Follow up
Link to previous question: Barnes-Hut N-body simulator
It still has issues I'm sure.
Node.h
...
15
votes
2answers
957 views
Barnes-Hut N-body simulator
I've 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 ...
5
votes
1answer
47 views
Gravity problem solver in Factor
After answering a question about Factor, I decided that it looked interesting. To get the hang of the syntax and such, I decided to write some basic physics code to "solve" the three-body problem. ...
7
votes
1answer
94 views
Basic physics simulation
I've been fooling around in JavaScript again, and I've come up with this simple physics simulation. I think it has a pretty simple setup, here's "psuedocode" of sorts to explain it.
Constructor ...
8
votes
4answers
2k views
Brute Force N Body Implementation in C++
I have wrote the following code in C++ for the n-body problem. This code is sequential as later on I am planning to parallelize it using OpenMP. I want to know whether I have wrote the correct ...
10
votes
1answer
320 views
Simulating a polygon
This code simulates a polygon (say a triangle) with a person at each vertex, every person is looking at the next adjacent vertex/person. They all start moving towards each other with a constant ...
7
votes
1answer
205 views
Quad Tree and Collision Detection Implementation
I have an implementation of a quad tree and abstract collision detection classes. The code works but looks very ugly, but I don't know what I could change to make it better.
The reason I used two ...
6
votes
4answers
543 views
A basic rocket controller for a Unity game
I'm currently learning C# so I can make real games with Unity. This is the first C# program I've built in Unity. Essentially what is does is control the thrust, and rotation of a ...
14
votes
1answer
589 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 ...
6
votes
1answer
700 views
Particle class for physics simulation
This is a very lengthy class called Particle, it relies on two other headers, one of them is a simple struct which contains an x and y (...
5
votes
2answers
99 views
Computing the RPY tensor with C++/Eigen (linear algebra)
I'm mostly used to writing scientific code in MATLAB / Python / Julia and my experience with C++ is very limited. I've implemented a fairly simple computation of the Rotne-Prager-Yamakawa tensor in ...
2
votes
1answer
92 views
Speeding up loop-rich Matlab function to calculate temperature distribution
I would like to speed up this function as much as possible in Matlab.
This is part of a bigger simulation project, and as it is one of the most called functions within the simulation, this is crucial.
...
16
votes
5answers
2k 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.
...
9
votes
1answer
169 views
Basic particle system
After about half an hour of fooling around with Processing.js/JavaScript, I got this fairly decent particle system set up:
...
3
votes
1answer
85 views
Trajectory optimizations
Here's a function doing some trajectory optimization in the following manner:
...
6
votes
3answers
589 views
Bouncing ball simulation
I was fooling around with some maths and realized that I could use a parabola to represent a bouncing ball. So, naturally, I decided to make it in code.
...
69
votes
4answers
8k 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 ...
3
votes
2answers
345 views
Calculating the push or pull force of a molecule at a vertex
The basic idea of the code is to calculate the push or pull force at a vertex, given the number of "push causing molecules" and "pull causing molecules" at a polygon vertex.
The code thus mainly ...
5
votes
1answer
209 views
Solving a one-dimensional Euler equation for fluid dynamics
I just wrote a program to solve one dimensional Euler equation for fluid dynamics. Attached is a snippet of the vtune profile result for one of the function.
There are a few things which looks weird ...
5
votes
3answers
124 views
Determining vehicle jump landing quality
I am writing a game where a car drives and makes jumps. When a jump is landed, the player is rewarded if they land all four wheels either at the same time, or near to the same time. If they don't, ...