# Calculate force of impact

BlitzMax Forums/BlitzMax Programming/Calculate force of impact
| ||

If I have objects that collide how do I calculate the force of the impact? Obviously if they are going in roughly the same direction at roughly the same speed the impact is minimal, but if they hit head on the impact is large. How do I calculate this from the two vectors? Thanks. |

| ||

calculate your Speed V in to 2 components Vx and Vy V1=speed Q1=angle Vy1 = sinQ * V Vx1 = CosQ * V use the above equation for both of object. you will get Vx1 and Vy1 for First Object , then Vx2, Vy2 for second object now. Vx = Vx1- Vx2 Vy = Vy1 - Vy2 direction of resultant vector Q = arctan (y/x), if you want resultant direction. or else. ignore this now. Vx1 + Vx and Vy2+Vy ( you get the resultant speed after collision, Vx2+Vx and Vy2+Vy ( for second object) use this as basic dynamic physics knowledge and convert to your program BTW, how to get your first and second object's speed? here.. how many pixels it moved from first Frame to second Frame that you show on display. that's the speed of your object. |

| ||

Ok, but from that how do I decide how much damage to inflict on objects 1 and 2? I want head-on collisions to do more damage than a glance or a nudge, so where how do I get the force of the impact? |

| ||

Here's some code directly from my game Ananta that features kinetic energy transformation in 30% elastic circle-to-circle collisions. It means 30% of the kinetic energy in a collision of two masses transform into damage. (Kinetic energy formula: E = 0.5 * m * v^2) CollEnergy is the energy in Joules that is will be used to inflict damage to the object, and is dependent of the objects' masses. Never bothered to actually check if the result is real-world-accurate, but it seems to work and looks good enough for me. Hope this helps some. |

| ||

ya. exactly. as Vilu say, E =0.5 m v^2 if you get, resultant Speed (V) then Force (F) = m v^2 m = mass of object on the other hand. you can simply specify, how much is your mass, and get the impact force. then decide how many percentage of FORCE is transform into damage into your object. If you want more complicated, then put density into consideration. such as more dense object will likely resist the damage and less dense will easy to break. that's is. |

| ||

Note that you should calculate the normal of the collision and the relative velocity between the objects along the normal. This is done in my code snippet above. If you just simply calculate their relative velocity, you can have "fatal" collision even if the objects only brace each other at a high velocity. |

| ||

Thanks guys. A big help. :) |

Blitz BASIC Founders Fund |