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
14
votes
2 answers

N body simulation in C++

I am trying to implement an OpenMP version of the 2-dimensional n-body simulation. But there is a problem: I assume each particle's initial velocity and acceleration are zero. When the particles first gather together, they would disperse out in a…
user3558391
  • 161
  • 2
  • 7
14
votes
5 answers

How to create an "intercept missile" for a game?

I have a game I am working on that has homing missiles in it. At the moment they just turn towards their target, which produces a rather dumb looking result, with all the missiles following the target around. I want to create a more deadly flavour…
Rik Heywood
  • 13,816
  • 9
  • 61
  • 81
13
votes
2 answers

Can I write multiple raku Type smart matches on one line

I know that this will not work, since I tried it: if $r ~~ BearingTrue || CompassAdj || CourseAdj { nextsame }; But - is there a neat, concise and legible way to do multiple Type smart matches on one line rather than have to expand to a given/when…
librasteve
  • 6,832
  • 8
  • 30
13
votes
5 answers

Orbital Mechanics

Does anyone have an example of implementing Orbital Mechanics (preferably in XNA)? The code I am currently using is below, but it doesn't "feel right" when it executes. The object just bends ever so slightly to the planet, and no matter how much I…
user60456
13
votes
2 answers

2D Elastic Ball Collision Physics

I am making a program that involves elastic ball physics. I have worked out all of the maths for collision against walls and stationary objects, but I cannot figure out what happens when two moving balls collide. I have mass and velocity (x and y…
0WJYxW9FMN
  • 231
  • 1
  • 2
  • 7
12
votes
11 answers

2d game physics?

Can anyone point me to a library for 2D game physics, etc for programming gravity, jumping actions, etc for a 2d platform/sidescrolling game ? Or could you suggest some algorithms for side scroller like mario, sonic etc?
Abhishek Mishra
  • 5,002
  • 8
  • 36
  • 38
12
votes
3 answers

Accelerometer calibration

I'm using the accelerometer to move something around in X/Y on the screen. This is easy if the phone starts flat on the table. I've come up with something in an attempt to be able to start at any given position, and work from there. But it doesn't…
Richard Taylor
  • 2,702
  • 2
  • 22
  • 44
12
votes
1 answer

Converting from Radians to Degrees

I'm building a small Physics engine and I'm having trouble converting my Radian value to Degrees using atan, as I need an angle to output in Degrees only. Firstly, I have an x and y value, and I need to find an angle using atan, so I divide y by x…
Lucy Loo
  • 171
  • 1
  • 1
  • 7
12
votes
2 answers

Will "Rubber banding" resolve multiplayer interpolation stutter?

I wrote multiplayer Pong using UDP. I am using interpolation and extrapolation in order to create a smooth looking effect on the client. It works. However, there is a bit of constant stuttering in the ball. It jumps a tiny bit forward every time a…
Z0q
  • 1,689
  • 3
  • 28
  • 57
12
votes
3 answers

Help with symplectic integrators

I'm trying to develop a physics simulation and I want to implement a fourth-order symplectic integration method. The problem is that I must be getting the math wrong, since my simulation is not working at all when using the symplectic integrator (as…
12
votes
5 answers

Ballistic curve problem

Ok i know this is quite off-topic for programmers but still I need this for app, so here it is: Ballistic curve (without wind or any other conditions) is specified by these 2 lines: So, there is a problem that you got 3 unknown values: x,y and…
Raven
  • 4,783
  • 8
  • 44
  • 75
12
votes
2 answers

Sprite Kit stop Impulse

I want to increase a CGFloat every time while the Screen is tapped. The float has a set maximum and minimum value. I tried to go through this suggestion: StackOverflow However, this only increases the CGFloat after the touch is made, or the maximum…
Nimbahus
  • 477
  • 3
  • 16
12
votes
6 answers

What mathematics is needed for a lunar lander game?

I'd like to build a game to learn cocos2d. Lunar lander is the first exercise coming in my mind. Any pointer/source code/tutorial of the physics calculations required will be appreciated. Thanks!
ohho
  • 50,879
  • 75
  • 256
  • 383
12
votes
5 answers

Detecting Acceleration in a car (iPhone Accelerometer)

I am working on an iPhone app where we are trying to calculate the acceleration of a moving car. Similar apps have accomplished this (Dynolicious), but the difference is that this app is designed to be used during general city driving, not on a drag…
TheGazzardian
  • 133
  • 1
  • 1
  • 8
12
votes
3 answers

Chipmunk Physics or Box2D for C++ 2D GameEngine?

I'm developing what it's turning into a "cross-platform" 2D Game Engine, my initial platform target is iPhone OS, but could move on to Android or even some console like the PSP, or Nintendo DS, I want to keep my options open. My engine is developed…
Goles
  • 11,599
  • 22
  • 79
  • 140