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
1 answer

Overlap Integrals in Python - Storing Results in Array

I have a set of basis functions defined as: def HO_wavefunction(x, n, x0, omega, m=1): N = 1.0 / math.sqrt(2**n * math.factorial(n)) * ((m * omega)/(math.pi))**(0.25) # Normaliziation constant y = (np.sqrt(m * omega)) * (x - x0) …
XBB
  • 109
  • 1
  • 13
1
vote
1 answer

Particle collisions with walls inside box

I want to simulate particle movement inside a box. When the particles hit one of the 4 walls in the box I want them to bounce back. Elastic collision [Drawing of velocity changes after collision][1] EDIT Added more code. Changed if test for (x,y,z)…
JimiChango
  • 13
  • 6
1
vote
1 answer

THREE.js: Can you force a different order of operations for three.js?

See this question: Threejs Transform Matrix ordering I'm drawing the orbits of the planets and having problems with changing inertial reference frames (I chose to align the three.js world coordinates with the viewed planet's inertial reference…
Boogiechillin
  • 276
  • 3
  • 19
1
vote
1 answer

Removing bodies from joints in Chipmunk Physics

In Box2D, when a body that is connected to a joint is removed from the space, the joint is automatically deleted and you can do stuff in callbacks and so on. Does Chipmunk do this? If so, how can I detect when a joint connection is 'broken'? Do I…
nornagon
  • 15,393
  • 18
  • 71
  • 85
1
vote
0 answers

Cocos2dx - How do i predict the movement of object if setVelocity returns different results?

I want to make synchronization movement between client and client. I've read some posts about simulate physics on the server and predict the movement on the client. However, how do i do it even if i have the formula if setVelocity on Physics engine…
TomSawyer
  • 3,711
  • 6
  • 44
  • 79
1
vote
1 answer

Unity 2d Ragdoll Inconsistent issue

I have a 2d character(side scrolling) with run/idle animations and movement works fine too. also character is attached with die/ragdoll script and this script does 1- disable animator 2- disable rigidbody(for whole character) 3- disable…
Yogesh
  • 1,206
  • 4
  • 22
  • 50
1
vote
1 answer

how to loop and store values from physics equations

so i want to do these equations in these steps q1*q3*k/(r^2)= F1_3(this is the electric force between 1 and 3) q2*q3*k/r^2)= F1_2(force between particle 1 and 2) from there i can find the net force between the two charges with f1_3+f1_2=fnet with…
Cosmik11
  • 25
  • 1
  • 7
1
vote
2 answers

Finding the direction of a ball after hitting a wall

I want to implement the following scenario in openGL c++. Suppose there is a ball moving around a surface and there is a boundary line in all the four direction. when the ball hits one of the lines, it reflects to a direction. My question is is…
user6823702
1
vote
4 answers

C# XNA Simulate Gravity

I have a question regarding using primitive shapes and simulating a circle to be free falling. How would I go about this? Do I use the formula for gravity?
RoR
  • 15,934
  • 22
  • 71
  • 92
1
vote
2 answers

Optimizing an n-body gravitational attraction algorithm

I'm writing a simulation of a 2d protoplanetary disk, and right now, the most time consuming bit of code is calculating the gravitational attraction. This is the code I'm currently using. for(int i=0; i
1
vote
1 answer

How to calculate the angles of the projection in 3d for an object to step at given point?

I need to calculate the angles to through the ball in that direction for a given speed and the point where it should land after thrown. The horizontal angle is easy(We know both start and step points).How to calculate the vertical angle of…
djkpA
  • 1,224
  • 2
  • 27
  • 57
1
vote
1 answer

OpenCL RK4 Integration on GPU

When parallelising an integrator using OpenCL - is it bad practice to have the whole loop in the kernel? I'm attempting to move an RK4 integrator I've written in C++ into OpenCL so I can run the operations on a GPU - currently it uses OpenMP. I need…
Dusted
  • 123
  • 2
  • 10
1
vote
0 answers

Correct Specular-Term of the Cook-Torrance- Torrance-Sparrow-Model

For a while I have been doing some research on the Topic of PBR and one reflection-models mentioned over and over is the Cook-Torrance-/ Torrance-Sparrow-model and it seems that in any mention or explanation of this model another form of the…
Thordal
  • 71
  • 3
1
vote
2 answers

Physics2D.OverlapCircle doesn't work

I have a problem with Physcis2D.OverlapCircle. In one tutorial i saw somebody use it as ground detector. I am trying to use it as something that checks if player is on top of a platform or not. What i did is i created empty gameObject on each…
Richarrd82
  • 97
  • 2
  • 11
1
vote
0 answers

array of shape nodes with physics collision properties

I have a SKShapenode creating a line that detects collisions but only for the first line. I can continue drawing lines after but only the first line has physics properties. How do I make an array of shape nodes that all will detect collisions?…
spapp
  • 41
  • 3