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

Calculate projectile landing distance and time

I am pretty new in Unity and I am building small games to learn. I am currently building a shooting-game and I have a small problem (miscalculation). Every time a player presses space key, I am creating new bullet (with RigidBody) and changes its…
SagiZiv
  • 932
  • 1
  • 16
  • 38
1
vote
0 answers

Using Input.Gyro to get the amount of "tilt" from an origin rotation

In my scenario, I have a table (plane) that a ball will roll around on using nothing but physics giving the illusion that the mobile device is the table using Input.gyro.attitude. Taking it one step further, I would like this relative to the device…
1
vote
1 answer

2D distance constraint

I've been trying everything to get a 2D distance joint working in Unity. I want free rotation to both the body with the joint and the connected body, I also need mass and other constraints adhered to, such as fixing a rigidbody's position. I've…
DwayneBull
  • 254
  • 3
  • 12
1
vote
1 answer

Give the player some friction when moving after being pushed

Not really sure how to word this but lets say you are a ball and are bouncing around and moving. Its a flat surface so everything moves fine. Now introduce some 45 degree ramps. You fall on one straight down and bounce away from it. At the moment…
Rachel Dockter
  • 946
  • 1
  • 8
  • 21
1
vote
1 answer

What happens when you apply force to the edge of an object?

I'm trying to build a 2D physics engine (rigid body dynamics simulation) in C#. So far I have simulated boxes (squares) of different sizes which are fixed in position but can rotate around their centroids (centre of mass) when a force is applied to…
Toxic Tom
  • 174
  • 12
1
vote
1 answer

Cannot add scalar and a vector error in VPyhton (GlowScript)

I'm implementing a solar system with VPython in GlowScript. Now I have received this error when running: Error cannot add scalar and a vector. I think I've done all correctly. Do I have to change something with the pos. ? Here is the…
CMC
  • 79
  • 1
  • 3
  • 11
1
vote
1 answer

How to find time and speed using iPhone's accelorometer

Let me tell you my physics is very bad. I want to calculate time between two points. The situation here is - if an object is moved from say point x to point y with an acceleration which is not constant, can we calculate the time between those…
Jayshree
  • 281
  • 1
  • 6
  • 28
1
vote
1 answer

Get results from sympy units

I'm trying to get some electrodynamics going with units in sympy. To check how i'm doing, i'm checking this relation: So i have defined mu0 and epsilon 0, and i would like to get the speed of light out: import sympy.physics.units as u import sympy…
nammerkage
  • 232
  • 2
  • 17
1
vote
1 answer

Scaling issues with OpenMP

I have written a code for a special type of 3D CFD Simulation, the Lattice-Boltzmann Method (quite similar to a code supplied with the Book "The Lattice Boltzmann Method" by Timm Krüger et alii). Multithreading the program with OpenMP I have…
2b-t
  • 2,414
  • 1
  • 10
  • 18
1
vote
2 answers

Combining two potentials in python

So I need to define the potential in python. I have infinite square well potential, and it has, in the middle the potential barrier. For the barrier I have this: V_x = zeros([Npts],float) for i in range(0,Npts,1): if x[i] > 0 and…
dingo_d
  • 11,160
  • 11
  • 73
  • 132
1
vote
1 answer

Calculating rotational speed of a GameObject, given a force at position C# Unity

I found this script that returns rotational speed (taking into account where force is applied and distance from center of mass). public Vector3 ForceToTorque(Vector3 force, Vector3 position, ForceMode forceMode = ForceMode.Force) { Vector3 t =…
RealAnyOne
  • 125
  • 3
  • 3
  • 17
1
vote
1 answer

Rings of Saturn - initial conditions

I'm working on a simulation of the Saturn system that will allow the user to, for example, increase the mass of its largest Moon Titan to that of Earth and see how the other moons and rings get perturbed as a result. My representation of the rings…
Happy Koala
  • 239
  • 1
  • 3
  • 10
1
vote
1 answer

the trajectory cannonball shot from the ground in c

I started to learn to code last year.Not very good though. I tried to plot the trajectory of cannonball shot from the ground using c language. (I didn't code this alone anyway). (# sorry I have to delete the original code for a while. If you would…
beginner
  • 37
  • 5
1
vote
1 answer

mono-energetic gamma ray mean free path

I am writing a code about a mono-energetic gamma beam which the dominated interaction is photoelectric absorption, mu=2 cm-1, and i need to generate 50000 random numbers and sample the interaction depth(which I do not know if i did it or not). I…
James
  • 35
  • 1
  • 5
1
vote
0 answers

Collision other than elastic/inelastic?

I want to make a 2d game similar to rocket league and I'm struggling with the physics engine. What I've gotten from my research is that there are elastic and inelastic collisions. Neither works for my purpose. Let's say ball A is at a standstill and…