Questions tagged [physics]

Refers to real-world physics. For simulation of physics in games use the [game-physics] tag instead, for questions using an existing physics engine use [physics-engine]. Physics is a science that studies the interactions of energy and matter. Questions with this tag concern the simulation or implementation of real-world physics concepts in programming.

The physics tag should be used for questions about how physics can be simulated or implemented in programming. Please ask questions about physics in a non-programming context on the Physics site. Also consider that questions specific to a simplified or approximate physics engine for use in games might receive better answers if asked on Game Development.

3476 questions
590
votes
15 answers

Cosmic Rays: what is the probability they will affect a program?

Once again I was in a design review, and encountered the claim that the probability of a particular scenario was "less than the risk of cosmic rays" affecting the program, and it occurred to me that I didn't have the faintest idea what that…
Mark Harrison
  • 297,451
  • 125
  • 333
  • 465
278
votes
15 answers

Ball to Ball Collision - Detection and Handling

With the help of the Stack Overflow community I've written a pretty basic-but fun physics simulator. You click and drag the mouse to launch a ball. It will bounce around and eventually stop on the "floor". My next big feature I want to add in is…
mmcdole
  • 91,488
  • 60
  • 186
  • 222
203
votes
2 answers

Why are my balls disappearing?

Pardon the funny title. I've created a little graphic demo of 200 balls bouncing and colliding, both against the walls and each other. You can see what I have currently here: http://www.exeneva.com/html5/multipleBallsBouncingAndColliding/ The…
Yang Pulse
  • 2,019
  • 1
  • 12
  • 13
118
votes
6 answers

Android accelerometer accuracy (Inertial navigation)

I was looking into implementing an Inertial Navigation System for an Android phone, which I realise is hard given the accelerometer accuracy, and constant fluctuation of readings. To start with, I set the phone on a flat surface and sampled 1000…
woodstock365
  • 1,780
  • 4
  • 19
  • 35
92
votes
20 answers

Practices for programming in a scientific environment?

Background Last year, I did an internship in a physics research group at a university. In this group, we mostly used LabVIEW to write programs for controlling our setups, doing data acquisition and analyzing our data. For the first two purposes,…
onnodb
  • 5,241
  • 1
  • 32
  • 41
72
votes
5 answers

Units of a Fourier Transform (FFT) when doing Spectral Analysis of a Signal

My question has to do with the physical meaning of the results of doing a spectral analysis of a signal, or of throwing the signal into an FFT and interpreting what comes out using a suitable numerical package, Specifically: take a signal, say a…
Assad Ebrahim
  • 6,234
  • 8
  • 42
  • 68
69
votes
10 answers

How to calculate bounce angle?

I played around with it for a while, but I simply can't figure it out. I made a tank that fires missiles, and when the missiles hit the walls, I want them to bounce off, but I want them to bounce off to the right angle. Right now I haven't got any…
Moulde
  • 3,438
  • 4
  • 29
  • 38
55
votes
3 answers

Runge-Kutta (RK4) integration for game physics

Gaffer on Games has a great article about using RK4 integration for better game physics. The implementation is straightforward, but the math behind it confuses me. I understand derivatives and integrals on a conceptual level, but haven't manipulated…
Kai
  • 9,444
  • 6
  • 46
  • 61
50
votes
8 answers

Game network physics collision

How to simulating two client-controlled vehicles colliding (sensibly) in a typical client/server setup for a network game? I did read this eminent blog post on how to do distributed network physics in general (without traditional client prediction),…
Jonas Byström
  • 25,316
  • 23
  • 100
  • 147
50
votes
9 answers

Heap space out of memory

My application currently consumes quite a lot of memory because it is running physics simulations. The issue is that consistently, at the 51st simulation, Java will throw an error usually because of a heap space out of memory (my program eventually…
randomafk
  • 783
  • 1
  • 8
  • 13
42
votes
8 answers

Resources for 2d game physics

I'm looking for some good references for learning how to model 2d physics in games. I am not looking for a library to do it for me - I want to think and learn, not blindly use someone else's work. I've done a good bit of Googling, and while I've…
Erik Forbes
  • 35,357
  • 27
  • 98
  • 122
35
votes
13 answers

How can I optimize my basic physics simulator?

I've written a simple physics modeler that allows me to bounce balls around the screen. You can click and drag to launch a ball, or you can generate balls hundreds at a time and watch them interact with each other. [Link to larger version] It has…
mmcdole
  • 91,488
  • 60
  • 186
  • 222
31
votes
6 answers

Simple physics-based movement

I'm working on a 2D game where I'm trying to accelerate an object to a top speed using some basic physics code. Here's the pseudocode for it: const float acceleration = 0.02f; const float friction = 0.8f; // value is always 0.0..1.0 …
Radek
  • 355
  • 1
  • 4
  • 8
30
votes
5 answers

How to make a 2D Soft-body physics engine?

The definition of rigid body in Box2d is A chunk of matter that is so strong that the distance between any two bits of matter on the chunk is completely constant. And this is exactly what i don't want as i would like to make 2D (maybe 3D…
Griffin
  • 2,399
  • 7
  • 48
  • 83
28
votes
12 answers

What are some algorithms that will allow me to simulate planetary physics?

I'm interested in doing a "Solar System" simulator that will allow me to simulate the rotational and gravitational forces of planets and stars. I'd like to be able to say, simulate our solar system, and simulate it across varying speeds (ie, watch…
Gaius
  • 349
  • 1
  • 4
  • 5
1
2 3
99 100