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
1
vote
0 answers

Game engine issue with maths/physics (movement of far items related to near items)

I'm developing a game engine. It's more complex but I will reduce the environment to a very little situation in order to explain my issue easily: The game is made in 2D using simple views. Some views are coming to the screen. The game engine…
NullPointerException
  • 36,107
  • 79
  • 222
  • 382
1
vote
0 answers

Is this a proper implementation of point charge dynamics with python ODEint

Since learning about point charges in my physics II class this semester, I want to be able to investigate not only the static force and field distributions but the actual trajectories of movement of electrically charged particles. The first stage in…
theideasmith
  • 2,835
  • 2
  • 13
  • 20
1
vote
1 answer

Snell's Law — how to deal with with invalid values in asin()?

Snell's law states that the ratio of the sines of the angles of incidence and refraction is equivalent to the reciprocal of the ratio of the indices of refraction of given materials: I wanted to implement a simple program to visualize the law.…
user7210680
1
vote
0 answers

Conservation of angular momentum

I'm working on a 2D physics engine in C#. I've got everything working other than resolving rotation during collisions. I have what I thought was a solution but it causes the objects to bounce insanely high and spin at high speed. I calculate the…
1
vote
1 answer

Mysterious factor of 150 on SpriteKit's Physics. Gravity and Forces

I wanted an object to float on the screen, resisting gravity, not moving at all. This is the gravity setting of the view. self.physicsWorld.gravity = CGVector(dx: 0, dy: 5.0) it's set to 5m/s^2 upwards. So object gets accelerated by 5m upwards…
1
vote
1 answer

Simple physics string

I am currently attempting to make a simple string simulation. The purpose is to just look like string but mine looks a bit weird and I don't know what the solution is. Does anyone have any ideas, here is the code from pygame.locals import * from…
adammoyle
  • 199
  • 1
  • 13
1
vote
1 answer

Physics for a towed bar

I am trying to implement a rigid bar which is pulled from one end, in Matlab. The initial coordinates of the points are P1(1,0) P2(0,0). I am using lumped mass model, where the weight is on the particles. The only existing efforts are a vertical…
galtor
  • 147
  • 6
1
vote
1 answer

Pygame orbit simulation issue

I have recently been making a orbit simulator using this equation: Here is my code: import pygame, math from pygame.locals import * from random import randint pygame.init() screen = pygame.display.set_mode([500,500]) clock =…
adammoyle
  • 199
  • 1
  • 13
1
vote
0 answers

How to control the velocity and position of a point when calculating Newton's law of gravitation?

I am trying to build a function that will calculate Newton's law of gravitation (G*M/r^2) of an object for a given timestep while being able to change the position and velocity of that point. As an example I will try to show what I have done to set…
Logic1
  • 1,806
  • 3
  • 26
  • 43
1
vote
0 answers

border restitution/bounciness not working (swift programming)

Excuse the naming conventions and the way I indent and create new spaces in my code I know it's not normal but i'm weird D: Anyway I set my restitution to 1 and it didn't seem to work so I even tried 1.0 to see if I had to do it that way and it…
Kenny Kiriga
  • 39
  • 1
  • 5
1
vote
2 answers

Computing tensor of Inertia in 2D

I'm researching how to find the inertia for a 2D shape. The contour of this shape is meshed with several points, the x and y coordinate of each point is already known. I know the expression of Ixx, Iyy and Ixy but the body has no mass. How do I…
liquid-snake
  • 73
  • 1
  • 9
1
vote
4 answers

Physics Engine (Collision Detection C#, GDI+)

I'm currently working on a 2D Game Engine in C# using GDI+ and have gotten to the point where I want to add simple collision detection. So far, I can check whether or not my player has intersected with another game object using the code…
user6943628
1
vote
3 answers

2D projectile - Velocity and Position Vectors

I'm building a small physics engine that launches a projectile with a given angle and velocity, and tracks and displays the velocity/position vectors at each time interval, but I'm having some issues with my program. When I run my program, it…
Ben Tanos
  • 51
  • 2
  • 8
1
vote
1 answer

How do I keep the angle of a body in pybox2d between -pi and pi?

In the pybox2d manual it states the following: pybox2d uses radians for angles. The body rotation is stored in radians and may grow unbounded. Consider normalizing the angle of your bodies if the magnitude of the angle becomes too large (use …
Bill
  • 10,323
  • 10
  • 62
  • 85
1
vote
1 answer

Fully replicable Javascript Physic 2D engine for netplay

Is there any fully replicable Javascript Physic 2D engine, so we can save state of simulation as a byte array for example, and load it in another machine (same architecture) so both simulation will do same next steps? I've already heard, Box2D have…
ElSajko
  • 1,612
  • 3
  • 17
  • 37