Module: Ballistics::Utils
- Defined in:
- lib/ballistics/utils.rb
Class Method Summary collapse
- .free_recoil(bullet_weight, propellant_weight, velocity, firearm_weight, propellant_velocity = 4000) ⇒ Object
- .kinetic_energy(velocity, bullet_weight) ⇒ Object
- .recoil_energy(bullet_weight, propellant_weight, velocity, firearm_weight, propellant_velocity = 4000) ⇒ Object
- .recoil_impulse(bullet_weight, propellant_weight, velocity, propellant_velocity = 4000) ⇒ Object
- .sectional_density(bullet_weight, bullet_diameter) ⇒ Object
- .taylorko(velocity, bullet_weight, bullet_diameter) ⇒ Object
Class Method Details
.free_recoil(bullet_weight, propellant_weight, velocity, firearm_weight, propellant_velocity = 4000) ⇒ Object
25 26 27 28 |
# File 'lib/ballistics/utils.rb', line 25 def self.free_recoil(bullet_weight, propellant_weight, velocity, firearm_weight, propellant_velocity=4000) recoil_impulse = recoil_impulse(bullet_weight, propellant_weight, velocity, propellant_velocity) return (ACCELERATION_OF_GRAVITY * recoil_impulse.to_d / firearm_weight.to_d) end |
.kinetic_energy(velocity, bullet_weight) ⇒ Object
13 14 15 |
# File 'lib/ballistics/utils.rb', line 13 def self.kinetic_energy(velocity, bullet_weight) return (0.5.to_d * bullet_weight.to_d * velocity.to_d ** 2.to_d / 7000.to_d / 32.175.to_d) end |
.recoil_energy(bullet_weight, propellant_weight, velocity, firearm_weight, propellant_velocity = 4000) ⇒ Object
30 31 32 33 |
# File 'lib/ballistics/utils.rb', line 30 def self.recoil_energy(bullet_weight, propellant_weight, velocity, firearm_weight, propellant_velocity=4000) free_recoil = free_recoil(bullet_weight, propellant_weight, velocity, firearm_weight, propellant_velocity) return (firearm_weight.to_d * free_recoil.to_d ** 2.to_d / (ACCELERATION_OF_GRAVITY * 2.to_d)) end |
.recoil_impulse(bullet_weight, propellant_weight, velocity, propellant_velocity = 4000) ⇒ Object
21 22 23 |
# File 'lib/ballistics/utils.rb', line 21 def self.recoil_impulse(bullet_weight, propellant_weight, velocity, propellant_velocity=4000) return (bullet_weight.to_d * velocity.to_d + propellant_weight.to_d * propellant_velocity.to_d) / UNIT_CORRECTION_FACTOR end |
.sectional_density(bullet_weight, bullet_diameter) ⇒ Object
9 10 11 |
# File 'lib/ballistics/utils.rb', line 9 def self.sectional_density(bullet_weight, bullet_diameter) return ((bullet_weight.to_d / 7000.to_d) / (bullet_diameter.to_d ** 2.to_d)) end |
.taylorko(velocity, bullet_weight, bullet_diameter) ⇒ Object
17 18 19 |
# File 'lib/ballistics/utils.rb', line 17 def self.taylorko(velocity, bullet_weight, bullet_diameter) return ((bullet_weight.to_d * velocity.to_d * bullet_diameter.to_d) / 7000.to_d) end |