• Advertisement

Archived

This topic is now archived and is closed to further replies.

An alternative to Integration?

This topic is 5866 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, So I'm trying to get my collision response working using various integration schemes, like Euler, Verlet, Runge-Kutta, etc. All of these try to figure out what happened to the position and velocity of an object after a certain time-step, using integration. I have another idea, and not being too math-orientated, I'm not sure if something similar to this are used already, or if it's even a viable alternative. Now, it’s late, and I’m tired, so I’m sure I’ll made a lot of mistakes in the formulas, etc, but I think it’s possible to get the idea. Anyway, I'll take an example of where an object hits a wall. You want to simulate the response to this. Let's say the wall (or the object, for that matter) is a little flexible. The general way is to use the spring method to simulate the flexing of the wall. In this formula the tension, or force applied to the object is a linear value that is directly proportional to the depth of the penetration. The resulting path of the object is that of one half of a sine wave. The time that the object spends penetrating the wall is always exactly the same, because it's one-half of an oscillating cycle of, let's say, a weight attached to a spring, and we know the amplitude does not affect the frequency. The value of w is given by: w = sqrt(k / m), where k is the spring constant (stiffness) and m is the mass of the object. The frequency of the spring would be f = w / 2pi. So therefore f is always constant for a given object and wall. The time the object will spend penetrating the wall is therefore (1 / f) / 2 for the half cycle. OK, fine. Now, my idea is, instead of using integration to calculate where we think the object should be after a given time-step, why don't we find the original formula that describes the path in the first place, and simply use this formula to calculate where the object will be after a given time-step? Since we know where is should be, as well as what it's new velocity should be, we can then even calculate the actual integrated force that should have been applied to get the object into that state, if we need that info. BTW, if we have the original formula that describes the path, we can calculate both the penetration depth as well as the velocity at any time. Something like d = D * sin(t * w), where d is the current penetration depth, D is the max depth, t is the time from when the penetration started, and we know f an w already, since they are constant. The velocity is v = V * cos(t * w), where V is the velocity at impact. The idea here is to work backwards, given current depth and velocity, to calculate D and V. Then we can advance the simulation by any time value, and know exactly what the object’s position and velocity would be at that next time. I know this might look a bit scary, but to calculate D (max depth), I think the formula should be: V = v / (cos(atan(d * k / v))), where V is the velocity at the instant the object just starts penetrating the wall (and the neg would be the exit velocity), v and d is the current velocity and depth. D would then be V / k. To calculate the exact depth of the object at any next time-step then, just use the formula we just calculated, like this: d = D * sin(t * w), where t is any time after the initial collision. To calculate velocity, use v = V * cos( t * w). Update the object’s position and velocity, and you should be all set, ready for the next time-step! Now, it’s obvious that you will first need to calculate the time at impact if it isn’t already penetrating the wall. For instance, if the object starts outside the wall, simply calculate the time it would take to get to the wall, and then work from that updated position, with t = 0 initially. The time it took the object to reach the wall must be subtracted from the time-step value to get to the right time it’s going to spend in the wall for the time-step. Similarly, if the time-step is large enough that the object would leave the wall, cut the time to the time it would be in the wall (time in wall is known), and at the end of the calculation, simply advance the object in a straight line for the remaining time. Basically, when the object is traveling outside the wall, use whatever method you use to advance the position and velocity, but for as long as the object is in the wall, use the method above. Since the sin, cos, and atan functions are pretty slow, I guess one can have lookup tables, etc. Am I crazy, and this is just not possible to do it like this, or what? Or is this something very common, and I’m just stating the obvious? I will test this theory sometime soon, but I was just curious to see if anyone tried this before, or know about it. SS Edited by - Axter on February 3, 2002 10:31:06 PM

Share this post


Link to post
Share on other sites
Advertisement
OK, the formula:

V = v / (cos(atan(d * k / v)))

...can be re-written as:

V = v * sqrt((v^2 + d^2 * k^2) / v^2)

In case that''s faster, I don''t know. Probably would be.

SS

Share this post


Link to post
Share on other sites
quote:
Original post by Axter
The idea here is to work backwards, given current depth and velocity, to calculate D and V. Then we can advance the simulation by any time value, and know exactly what the object’s position and velocity would be at that next time.

That''s what integration does.

Share this post


Link to post
Share on other sites
Certainly the point of the integrating the kinematic equations of the system is to solve, online, the estimation and prediction problems for all t. If you have a closed form solution to the integral (as you are suggesting) then obviously this should be used instead of online integration... that''s just common sense.

The point of integrating though is that for an arbitrary non-linear kinematic system of the form

dx = f (x t,t )dt

there is no general closed form solution F (x t,t ) such that dtF (x t,t ) = f (x t,t ) for all x and t.

It gets even worse if the kinematic transitions are non-deterministic (i.e., stochastic) as they are when modelling real-world systems.

Cheers,

Timkin

Share this post


Link to post
Share on other sites
quote:
Original post by Timkin
Certainly the point of the integrating the kinematic equations of the system is to solve, online, the estimation and prediction problems for all t. If you have a closed form solution to the integral (as you are suggesting) then obviously this should be used instead of online integration... that''s just common sense.

The point of integrating though is that for an arbitrary non-linear kinematic system of the form

dx = f (x t,t )dt

there is no general closed form solution F (x t,t ) such that dtF (x t,t ) = f (x t,t ) for all x and t.

It gets even worse if the kinematic transitions are non-deterministic (i.e., stochastic) as they are when modelling real-world systems.

Cheers,

Timkin


OK, I think then the problem is that this would only work for simple cases where the depth/force ratio is linear, if I understand you correctly. Anything more complex would probably not be possible.

Well, I am going to test the method I mentioned for simple plane collisions, just to see what happens. I do not have non-linear systems, so this might work for that.

The biggest problem I''m trying to solve is how to handle cases where there are multiple-plane collisions. It seems the only way to solve this is to have soft walls, where some penetration is allowed so that multiple collisions would end up with the correct response. But so far the time-steps cause instability.

Anyway, I''ll keep trying...

SS

Share this post


Link to post
Share on other sites

  • Advertisement