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.

6 votes
3 answers
248 views

Calculate next position and velocity after "bounce"

Intro and code I have the following function that calculates an object's "next" position and velocity (in 1 dimension) given a boundary [0, max]. ...
geofflittle's user avatar
6 votes
1 answer
484 views

Pong Game in JS

I am new to game development and took on the task to create a Pong replica due to my curiosity and interest in the field. I decided to write it in JavaScript because the game is not too labor ...
Shawn31313's user avatar
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
3 votes
2 answers
670 views

Simulating a system of moving points

This is an update of the code from my previous question. I'm simulating a system of particles which interact with each other and move and rotate due to the interaction. There are 2000 particles in ...
codder code's user avatar
1 vote
2 answers
404 views

Simulation of interacting particles [closed]

I'm simulating a system of particles which interact with each other and move and rotate due to the interaction. There are 2000 particles in total but each particle interacts with other particles and ...
Oliver Range's user avatar
2 votes
2 answers
3k views

Simulating motion of particles

Description The code does particle simulation. In this code, some particles take steps with a certain distribution length. if particles go beyond a curve, the code put them back. Code ...
codder code's user avatar
2 votes
3 answers
4k views

Calculating work using dot product in C++

Write a C++ program fulfilling the following task: The user should enter the 3 dimensional force vector F and a 3 dimensional length vector s. The force is assumed to be constant. The program then ...
Patrick Moloney's user avatar
2 votes
1 answer
594 views

Cross product to find Lorentz force in C++

User enters velocity vector \$v\$, charge \$q\$ of particle and magnetic field vector \$B\$ and the code prints the Lorentz force \$F = q * (v * B)\$ ...
Patrick Moloney's user avatar
10 votes
3 answers
1k views

Feynmann lifeguard riddle graphical representation

Physicist Richard Feynman though of a very interesting riddle: Imagine you are a lifeguard at the side of the beach and there is a child drowning in the water. (You must cross both sand and water to ...
Caridorc's user avatar
  • 27.5k
1 vote
1 answer
274 views

Closed particle system simulation in vanilla Javascript

I have ported my simulation from Java to vanilla Javascript. The most important aim was to keep the sum of all energies constant. I have this: simulation.js ...
coderodde's user avatar
  • 28.9k
4 votes
3 answers
2k views

Simulating a closed particle system in Java

I have this program that simulates a closed particle system. Closed in this context means that the sum of all energies is constant. My primary concern is code itself, yet I would like to hear comments ...
coderodde's user avatar
  • 28.9k
2 votes
1 answer
65 views

NodeJS module to calculate linear motion

I am on the process of changing jobs, so I would like to get an idea of what I do wrong in order to improve. For this, I have created a small node module. It's very simple; it calculates linear ...
yBrodsky's user avatar
  • 123
7 votes
1 answer
635 views

Metaballs and Gravity game;

For past two days I made my first OpenGL project, I know, It's fixed pipeline, but my focus was on gravity algorithm, so, tell what do you think, and how can I make it faster? main.cpp ...
iUuax's user avatar
  • 73
2 votes
1 answer
3k views

2D Physics Simulation (game-like)

My program is meant to simulate 2D physics(hopefully 3D as well in the future), namely classical mechanics and eventually electromagnetism. Currently it simulates projectile motion by firing a ...
defoification's user avatar
2 votes
2 answers
6k views

My first Physics Engine C++

I have made my first physics engine for simulating circles in a plane. Let me know what you think about it. ...
Harmohit Singh's user avatar

15 30 50 per page
1
3 4
5
6 7
11