# collission physics...

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

## Recommended Posts

I have a spaceship(in 2d) made from several independant modules and the girders holding them together, and I've come to the point where I calculate collisions, interactions, etc. Each module has it's own location, and is of fixed shape and size, and also of (mostly) fixed position relative to the rest of the ship. Modules are held in place by girders. Girders will be straight, and can be of any length and at any angle. They will connect modules to a structural node. A strucural node can have several girders coming off of it, and can be connected to other structural nodes by girders. I am primarily concerend with the girders, and what sort of abuse they will endure, but I am also concerned with the modules, and whether they can successfull translate the impact energy of a direct hit into the girders without being squashed. I need to be able to apply a force(engines firing) or impulse(KE weapons firing) to a particular module or structure, and calculate whether the adjacent structure(s) break, deform permanently, or flex temporarily. I'm guessing I'll need somehting like the Coefficient of Restitution to determine how much of the energy is absorbed by the materiel, and how much goes into flexing. Hmm... THat doesn't seem to be it exactly. I'm sure I'll also need to take into account things such as the ultimate yield strength(to see if it breaks), the elastic limit(to see if it is permanently deformed) youngs modulus(if it doesn't break, to see how much it bounces by). The thickness of the girder will be predetermined. The problem with yield strength and elastic limit is that they are in pascals, which means it takes a force to deform stuff, not an impulse. Is there an analog of these things that deals with impulse? My main questions and points of discussion are these: How can I figure out whether a module is crushed outright by a force or impulse? How can I figure out

##### Share on other sites
No, because in real life it is the force that does the damage. Drop a glass onto a trampoline or the ground and the impulse is larger on the trampoline, as the glass ends up travelling in the opposite direction, but the force is much larger on the ground so the glass breaks.

You need to divide the impulse by the estimated time over which it occurs to get the force back; either that or you need to use a real physics system which works out the forces sufficiently accurately (and fast) that collisions work right.

##### Share on other sites
Hmm... You speak the truth. It seems to me that I need a quick and dirty attribute for structural materials that can take impulse and determine a collision time. Something along the lines of elasticity. A higher elasticity will result in longer contact time. More momentum results in more contact time.

so....

impulse * elasticity = contact time
contact time/impulse = force

So basically, if you have two modules connected by a girder, and you hit one of them towards or away from the other, part of the impulse is transmitted straight to the other one, and part of it is absorbed by the spring of the girder.

Or even better, ALL of the absorbed impulse is used to accelerate the module that was hit, and to keep that module consistent with the rest of the ship, the component of the module's velocity along the vector of the girder is used to calculate the kinetic energy absorbed by the spring of the girder. quite a bit of that spring energy is released back into the modules at either end as part of that very same frame. The component of the module's velocity perpendicular to the direction of the girder becomes torque.

So what I really want is not elasticity, but spring constant.

Have I got it right? does it make sense?

##### Share on other sites
I didn't quite get everything in your last post, but I can see a major error in your equations:
Quote:
 impulse * elasticity = contact timecontact time/impulse = force

By substitution that gives you:
impulse*elasticity/impulse = force
or
elasticity = force

Time is a base unit so it's something that, if possible, you should try to get directly from your simulation. However if you can't do that and if higher elasticity means less stiff then you might be able to pull off (elasticity = contact time). Though hacks like that always have the potential to cause problems later.

##### Share on other sites
impulse is nothing but force for a certain time:

impulse=force/time

a force of 5, delivered in 10 seconds, is equal to an impulse of 2 per time frame. While if the force was delivered in 0.1 time, then the impulse would be 50.

In essence, elasticity and impules are the same. Impulse results in all force being accounted for, through time, while elasticity is the ratio of absorbtion, or more like transfer.

With an impulse of 1, the energy is transfered in one time frame
With the elasticity of 1, the energy is transfered in one time frame.

With an elasticity of 0, both objects carry the same velocity.
With an impulse of 0(force other than 0), both objects nearly carry the same velocity, because the impulse will go for infinity.

BTW, i'm not sure if this cleared anything up, or stated the obvious. Hmmm, maybe did neither. Also i could be totally wrong.

##### Share on other sites
I did something extremely similar to what you are proposing. Physical spaceship components linked with "girders" (in reality, they were just springs).

A prototype of the game and the source code is available here:
http://homepages.ihug.co.nz/~flat816/Ship%20Builder%20Prototype%20-%20No%20Damage.rar
http://homepages.ihug.co.nz/~flat816/
It's pretty poorly commented and ad-hocly coded, but you might get something out of it.

However, I abandoned the project for a number of reasons:
1. It ran very slowly, because the computer had to perform collision detection for every component.
2. Even with RK4 integration there are limits to how high I could set the spring constant, so the ships ended up being floppy and hard to control.
3. For the amount of time I put into programming it, it simply wasn't that much fun.

In hindsite, a much better way to do it would have been to have the ship represented by a single chasis, and then attach parts to that (eg, on top of it, within the borders of the chasis), rather than have them all linked together by girders. This way would be better because:
1. It would run quickly, collisions only have to be determined against one polygon (the chasis). If you still want to damage individual components, use the chasis for collisions with other ships, and simply use circle/ray (guns or lasers hitting components) or circle/circle (missiles or bombs hitting components) collision checks.
2. The ships wont feel floppy. Have every thruster apply it's force directly to the chasis centre of gravity, rather than having it slowly disperse through the ship.
3. It would be more fun because the ship would be more responsive. The game would be easier to code, collisions would feel better.

Having said that, it could have been a problem with my implimentation/collision detection/integration or any one of a hundred other things, and you could do a much better job of it. I just wouldn't want you to make the same mistake I did.

[Edited by - CIJolly on June 12, 2006 6:09:34 AM]

##### Share on other sites
Why do you bother with real physics at all? Alot of those things can be done with fake physics and especialy when your working in 2D. Your waisting your time on a thing that can be done 1/10 of the time and look just as good.

##### Share on other sites
For some reason(hmm...), real physics look much better, of course it can be tweaked for a better appeal.

Hey check this out: http://physical.alecrivers.com/

This physics engine use the spring model, and sprite deformation. It's pretty sweet graphics.

##### Share on other sites
The physical demo is another good example of why I would steer away from simulating 2D ships with springs. It's an interesting concept, and fun to play with in a novel way, but the ship just isn't responsive enough. Most of the challenge comes from steering the unwieldy ship.
Using a ship simulated this way it would be extremely difficult to dodge projectiles and perform fun maneuvers.

In my demo I added a feature where the cockpit could be ejected and flown around on it's own after your ship was crippled. It was much more fun than dealing with the springy ship you had previously built.

##### Share on other sites
Actually, I like the way that the springs keep the ship together. That's eactly what I was thinking for my game. I will use a higher spring constant, so the ship is less wobbly, and I'll allow the spring to break at a ceratin amount of force, according to the yield strength of the material from which it is made. How do you deal with torque?

1. 1
2. 2
3. 3
Rutin
20
4. 4
frob
18
5. 5

• 32
• 13
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
632561
• Total Posts
3007088

×