Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / shockwave velocity effects nearby object velocities?

Author
Message
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Apr 2012 16:43
I thought this would be a simple problem, but I haven't gotten the effect I wanted. I have several asteroids floating around, each with a specified direction unit vector and a velocity speed (and current position ofcourse). Then shockwave knowns are its center and rate of expansion. From that I can calculate the nearest point on that shockwave circle where the asteroid should make contact.

What I'm trying to is have the shockwave push the asteroids out away from its epicenter. The closer they are the harder they get smacked away. I can't seem to get them to do this smoothly. Any thoughts or theories on the physics?

"You're not going crazy. You're going sane in a crazy world!" ~Tick
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 29th Apr 2012 20:03 Edited at: 29th Apr 2012 20:16
If you want this to be physically correct, then the force of the shockwave on an asteroid is inversely proportional to the distance of that asteroid from the center of the shockwave squared. (because at any given time the shockwave is a sphere, and the surface area of a sphere is proportional to the square of the radius)

In the simplest case, the shockwave is very thin, so you can just apply a one off impulse on each asteroid as the shockwave reaches it. The impulse will be proportional the surface area of the asteroid facing the center (which you can easily approximate by assuming the asteroid is roughly spherical) and inversely proportional to its distance squared. Of course that impulse is then divided by the asteroids mass to calculate the change in velocity.

If the shockwave is not thin then it will have an inner and an outer radius. The behaviour will be the same as before but instead of applying a single impulse, you apply a force for the duration that an asteroid is between the inner and outer radii of the shockwave. This will give the effect of asteroid "riding" the shockwave for a period of time before getting left behind.

So:
r = approximate radius of asteroid
R = distance of asteroid from centre of shockwave
s = approximate density of asteroid
M = strength of shockwave

Impulse (applied once):
change in velocity = M r²/(R² s r³) = M/(R² s r)

Force (applied while asteroid is in the shockwave):
acceleration = M/(R² s r)

As you can see from these formulae, denser and larger asteroids, and asteroids further from the center of the shockwave will be less affected.

The rest is just standard newtonian physics, ie. integrate acceleration to get velocity, integrate velocity to get displacement.

[b]
mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 29th Apr 2012 20:59
Quote: "If you want this to be physically correct"

I think in space there will be energy wave like EMI and particle wave from blast that will be fade by inverted square from radius, but no shock wave. What will move your asteroids? Air?

«It's the Shader, shader me this, shader me that»
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Apr 2012 21:22
I had a crude proportion to control the amount of force based on the distance of the asteroids. I was applying the force as long as the shockwave's circle was overlapping the radius of the asteroid.

How I was applying the forces was as follows:

A = asteroid direction vector
S = shockwave's direction vector in relation to position of asteroid from the epicenter.
v = asteroids velocity (scalar)
f = Shockwave's velocity force (scalar)


R = A*v + S*f

Adding them together with their velocity forces so to give weighted values of the two, if that makes sense. Then normalize R back into a unit vector. But then I'm unclear on the amount of velocity that new vector should have for future movements.

I have an idea now, after trying to put together a quick demo.

"You're not going crazy. You're going sane in a crazy world!" ~Tick

Login to post a reply

Server time is: 2026-07-10 22:26:24
Your offset time is: 2026-07-10 22:26:24