physics

Simulating two circles bouncing off each other

↘锁芯ラ 提交于 2019-12-08 10:17:58
问题 I have many particles moving around and hit detection to see when they touch. If two particles touch they should bounce off in the opposite direction. particle.moveSelf = function() { var radians = this.angle * Math.PI / 180; var moveX = this.velocity * Math.sin(radians); var moveY = this.velocity * Math.cos(radians); for (var i = 0; i < particles.length; i++) { var distance = this.position.getDistance(new Point(particles[i].position.x, particles[i].position.y)); //if distance < radius 1 +

The momentum is not conserved after collision resolution between balls

南楼画角 提交于 2019-12-08 07:14:36
问题 I have a problem in collision resolution between balls. Actually collision responses are very realistic but the momentum is not conserved, why? I use an algorithm based on this document: http://www.vobarian.com/collisions/2dcollisions2.pdf. In Java code my algorithm is: /** * Resolve the collision creating new velocities according to physical laws. */ public void resolveCollisionWith(Ball ball) { //First resolve intersection for calculate correct new velocities. resolveIntersectionWith(ball);

find a way of fixing wrong collision normals in edge collisions

早过忘川 提交于 2019-12-08 05:57:37
问题 The main problem is that Bullet 2 (2.82, to be specific - and perhaps Bullet 3 too, haven't checked it yet) processes edge collisions lousily, generating skewed reaction normals. Test case 1: a small btBoxShape , positioned (0,9,0), aligned vertically, falls onto another box's (made from btBoxShape also) face, coaligned. The normal is computed properly, the collision happens only in Y (vertical) axis. The box slightly bounces on OY axis and stays centered around it. Test case 2: a small box,

How to fix circles overlap in collision response?

南笙酒味 提交于 2019-12-08 05:48:31
问题 Since in the digital world a real collision almost never happens, we will always have a situation where the "colliding" balls overlap. How to put back balls in situation where they collide perfectly without overlap? I would solve this problem with a posteriori approach (in two dimensions). In short I have to solve this equation for t: Where: is a number that answers to the question: how many frames ago did the collision happen perfectly? is the center of the first ball is the center of the

Rigid body (shape) in bullet/ammo.js from a mesh in three.js

寵の児 提交于 2019-12-08 05:10:30
I am using bullet/ammo.js with three.js. I have a 3d mesh and I want to use the exact shape for collision detection with a soft body. Is there a way I can create a 3d rigid body (in bullet) from a mesh (in three.js)? Here is an example: http://kidzinski.com/miamisura/lazy3d/ (please wait a second for the 3d model to download). I have a cloth falling on a 3d body and I need to simulate collision of this cloth with the body. I am new to these frameworks sorry if I fundamentally misunderstood something. It looks like you can do some work to turn an arbitrary Three.js mesh into a Bullet concave

Not a number error (NAN) doing collision detection in an iphone app

吃可爱长大的小学妹 提交于 2019-12-08 03:30:04
问题 I have a set of balloons that I am trying to get to bounce off of each other like balls. When I start to move them and then detect collision, the routine for the collisions eventually returns a NAN for the velocity of the balloons. I end up with a position of something like x=270, y= -nan(0x400000). I've been looking at the code all day and I still can't find the error, any help would be appreciated. Here's the code: - (void)MoveBalloons { for (CurBalloon=1; CurBalloon <= NumBalloons; +

Bouncing ball in Bullet

大城市里の小女人 提交于 2019-12-08 03:05:48
问题 I have two questions with regards to Bullet, but they are related. In the HelloWorldApp, the objective is to get a ball bouncing on a box right? If I wanted to test a plane, could I just add in a btCollisionObject with a btStaticPlaneShape instead of the box? How can I set custom restitution, static and kinetic friction per object? 回答1: Yes, I believe that should be correct Restitution and friction can be set per object by supplying them to the btRigidBodyConstructionInfo object passed into

Detect physical movement of iPhone/Apple Watch

℡╲_俬逩灬. 提交于 2019-12-08 02:27:14
问题 I'm trying to detect the movement (to the right or left) performed by users. We assume that the user starts with his arm extended in front of him and then moves his arm to the right or to the left (about 90 degrees off center). I've integrated CMMotionManager and want to understand detecting direction via startAccelerometerUpdatesToQueue and startDeviceMotionUpdatesToQueue methods. Can anyone suggest how to implement this logic on an iPhone and then on an Apple Watch? 回答1: Apple provides

SpriteKit joint: follow the body

…衆ロ難τιáo~ 提交于 2019-12-07 16:11:26
I've been asked to simplify this question, so that's what I'm doing. I'm struggling in SpriteKit's physic joints (and possibly physic body properties). I tried every single subclass and many configurations but seams like nothing works or I'm doing something wrong. I'm developing Snake game. User controls head of snake which should move at constant speed ahead and user can turn it clockwise or anticlockwise. All the remaining snake's pieces should follow the head - they should travel exactly the same path that head was some time ago. I think for this game the Pin joint should be the answer,

Calculating collisions in realtime - dealing with a delay in time

我怕爱的太早我们不能终老 提交于 2019-12-07 15:22:37
问题 Suppose: you're coding a program in which 3 (or a lot more) circles (or other geometry) move around on the screen in realtime, all with a different velocity, that can change at certain times due to physics-calculations. the calculations can only be calculated on every frame each frame, you have to make sure the circles who "collide"/"have collided during the time between this frame and the last" with eachother will 'bounce off' by using physics-calculations Suppose that during the time