2
$\begingroup$

I am working on a 2D game that has a shield in it (think scifi energy shield) that can apply a force to objects intersecting the shield boundary, to slow them down, or accelerate them however it wants. This can be thought of as a collision that occurs between the object and the shield boundary with a coefficient of restitution that may be <0 or >1, because the shield will experience the equal and opposite force it applies to the object. My overarching goal is to put a price-tag (in Joule) on forces/impulses that the shield applies to objects. That price-tag should obey two properties:

  • It should be at least equal to the amount of energy added to the system (when the restitution coefficient is <-1 or >1) to not break conservation of energy
  • It should increase with the change in momentum, because energy is a resource in my game, and the more work the shield does, the more it should cost.

I identified two calculations I need to be able to do in order to reach my goals:

  • Find the amount of energy necessary to slow an incoming object to a given target speed in a given amount of time.
  • Find the resulting speed that an object can be slowed down to for a given amount of energy in a given amount of time (the inverse). This is necessary because the shield requests energy but might not get everything, which means the target speed might not be reached.

3 simplifications can be made:

  • The problem is 2D in my game, but since I only apply forces and consider speed along the shield normal, this can be treated as 1D without loss of generality.
  • The forces may be applied off-center, so torque is involved, but again, there are ways to precompute this, so it can be treated as if there were only linear motion involved.
  • In the game, when the shield pushes on the object the object pushes back, so there are two bodies that change motion. I think this can be disregarded, one can just talk about relative velocities and so on, and treat the sield as not-moving, but not 100% sure about that.

So far I was not able to find a solution for the second calculation (energy->speed)

My first approach was to just use the change in kinetic energy of the body when decelerated to target speed as the energy cost, but I am not sure if this is correct: Finding the resulting velocity for a given amount of energy has two solutions, since an object with 10 m/s has equal energy to an object with -10 m/s. I implemented this and I encountered cases where it was unclear to me which of the two solutions is the correct one. My takeaway from this was that the delta in kinetic energy did simply not represent the price tag I am looking for: For $0J$ cost the shield can theoretically send an incoming object in any direction it wants, as long as the speed of that object stays the same. That doesn't make sense.

My second approach was to find the work the shield was doing. To my understanding, I can use $W = Fs$ (Work is Force applied over distance) for that: If I can figure out what distance the object travelled while the shield was applying the force to it, I know how much work was done, and since work and energy have the same unit, I also know how much energy this consumes (assuming 100% efficiency and that this magical device somehow does its job).

Given

$$s = v t + \frac{1}{2}at^2$$

$$F = ma$$

$$W = Fs$$

I can construct the following equation

$$s = vt + \frac{Wt^2}{2sm}$$

multipying with s and rearranging gives

$$0 = -s^2 + vts + \frac{Wt^2}{2m}$$

I thought solving for s would give me the distance, and then I can plug s and the given W into $F = \frac{W}{s}$ to find the force, but plotting this equation and playing around with possible values made me realize that this doesn't behave in the way I thought it would. For example, for the parameterisation v = -2, t = 1, m = 1 (see the plot), with W = 0, solutions are s=-2 (which makes sense because it travels at -2 m/s and the velocity doesn't change) and s=0 (not sure what this solution represents?), but with W = 1 solutions are now s<-2 (it got faster??) and s>0 (still...?). I thought maybe I got some sign wrong with W, (e.g. for W=-3 there is a solution s~-1.5 which looks plausible for a deceleration), but for W=-5 there simply are no solutions anymore, which absolutely doesn't make sense to me. So I think I have a fundamental misunderstanding about what this equation expresses, or maybe of the problem as a whole.

I hope someone can point out where I am going wrong here, and what the actual solution looks like. Is the basic goal of putting a price-tag in Joule on what is basically a collision even achievable?

$\endgroup$
8
  • $\begingroup$ 2D in the sense there is like both vertical and horizontal motion on a plane? $\endgroup$ Dec 28, 2021 at 16:18
  • $\begingroup$ Because energy goes as the square of the velocity you have to divide the problem into two parts: the energy to slow the thing to zero plus the energy to achieve the final speed. $\endgroup$
    – garyp
    Dec 28, 2021 at 18:39
  • $\begingroup$ Or instead of considering the work done on the object, calculate the work done by the force. In the one-dimensional case of an object being slowed to zero, reversing direction, and speeding up, the force and displacement are always in the same direction $\endgroup$
    – garyp
    Dec 28, 2021 at 21:28
  • $\begingroup$ @AdilMohammed yes. There are 2 translationional degrees of freedom and 1 rotational degree of freedom. In my game you basically have an overhead view on a plane, although the exact direction doesn't even matter because there is no implied direction of gravity. $\endgroup$
    – pulp_user
    Dec 29, 2021 at 11:31
  • $\begingroup$ @garyp I tried the approach of calculating the work done by the force as my second approach, and it led to the problems I described in the question, where the plot doesn't behave in a way that I understand. I'll think about the approach of dividing the problem in two parts. That may work, although I'm already a bit sceptical because for example if an object only gets decelerated a tiny bit there wouldn't even be two phases because the velocity wouldn't cross 0. That means I have to detect and handle those cases differently. Seems a bit inelegant, but if it works out I'll take it. $\endgroup$
    – pulp_user
    Dec 29, 2021 at 11:37

3 Answers 3

1
+50
$\begingroup$

In my opinion your problem is a misunderstanding in the definition of work. If you want to slow down a car, it is not you who does work on the car, but the car does work on you. Let's say the car goes towards the right and you are pushing it to the left. By definition you are doing a negative work, because the dot product of the force (pointing to the left) and the displacement (pointing to the right) is negative. Now when you accelerate this car (after it has stopped moving) the same product of the force and displacement is positive, meaning that now you do work on the car, increasing its kinetic energy.

The fact that the total change in the kinetic energy of the car is zero is of no surprise: first the car does positive work on you and then you do the same amount of positive work on the car. Think about this as a ball colliding with a spring. First the ball slows down by the force that the spring applies to it, but the spring does negative work on the ball. It is the ball that does positive work on the spring. After the ball stopped the spring now starts to push it back and does positive work on it. At the end of the day, the kinetic energy of the ball is the same while the potential energy in the spring is zero. Energy conservation is happy.

Hope this helps.

$\endgroup$
1
  • $\begingroup$ This is helpfull, but I am not 100% sure as to what that means for the price tag I am looking for. Is your suggestion then to use the absolute sum of negative work and positive work as the price tag? Basically the approach that garyp suggested in the 2nd comment to the original question, but using work and not energy? Because while the object being slowed down might do work to the shield, I still want to shield to pay for this. Or are you saying I simply can't put a price tag on that in the way that I want to? $\endgroup$
    – pulp_user
    Dec 30, 2021 at 14:57
0
$\begingroup$

The time taken to slow down the object is irrelevant. Start with

$$v^2-u^2=2as$$

If the object is being slowed down then $W=-Fs$ and you have

$$v^2 - u^2 = - \frac {2W} m \\ \Rightarrow W = \frac 1 2 m (u^2 - v^2)$$

In other words, work done on object = decrease in kinetic energy. You can either set $v=0$ and find the energy needed to stop an object with initial speed $u$, or fix $W$ at some value less than $\frac 1 2 mu^2$ and find the final speed of the object after work $W$ is done on it

$\endgroup$
1
  • $\begingroup$ I don't see how this is different from my first approach, where I just used the kinetic energy. The problem with that was that e.g. for u=-10 and v=10, the object changes velocity by 20 m/s but W=0. Using W as the price tag doesn't work, because in that case the shield changed an objects velocity by 20 m/s for free. And for a given W I also get two solutions for what the resulting speed might be, with no way to tell what the "intended" one is (and then there is also the question what "intended" even means in this case). $\endgroup$
    – pulp_user
    Dec 28, 2021 at 12:13
0
$\begingroup$

Ahh it seems (at least in part) that you are struggling with the difference between change in momentum vs change in kinetic energy. This is a problem that haunted me for years!!! Until finally I came to understand that momentum is a vector quantity whereas kinetic energy is a scalar quantity.

Here is a good post which sheds light on the subtleties: Kinetic energy vs. momentum?

So the delta in momentum ( mass * velocity ) is probably going to be part of your answer.

A ball changes momentum by (mass * velocity * 2) when it bounces perfectly elastically off of another object.

So the momentum of your shield+body should change by the opposite value of the projectiles ‘ delta in momentum..

Say if ball weighs one pound, with vel. 10 m/s, and if body+shield weighs 10lbs, then the body+shield momentum should change by an equal and opposite amount: 0.2 m/s.

I don’t have equations to answer to your question, and I’m inclined to think that you are going to have a system of differential equations in the end. (Someone else will likely point to the equations and/or source code you’ll need). A quick google search of “source code for solving for collision between 2 bodies momentum kinetic energy 2d elastic collision.” revealed some promising codebases.

$\endgroup$
1
  • $\begingroup$ Unfortunately your answer doesn't really solve my problem. I know how all the bodies should move after the "collision", what impulses are needed where to achieve the movement and how to implement it (for 2 bodies, you can solve it without differential equations). The question is purely about how to put a price tag on the work that this fictional device does, in a way that it doesn't break the laws of physics, because with a coefficient of restitution >1, energy is added. I edited the first paragraph of the question to reflect that. $\endgroup$
    – pulp_user
    Dec 28, 2021 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.