Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Caluculating Muzzle Velocity of Historic Guns

Discussion in 'Scripting' started by boddole, Oct 1, 2014.

  1. boddole

    boddole

    Joined:
    Sep 18, 2013
    Posts:
    35
    Hello everyone, I'm working on a project that involves needing to get a decent idea of what the muzzle velocity of certain guns are (for this example, the XI inch Dahlgren naval gun).

    All I can gather is the gun's projectile weight, and a max range at a given elevation. I've looked up formulas for calculating muzzle velocity but they all require more known input than what I can find. Is it possible to even derive a decently accurate muzzle velocity with my known values?

    Any ideas are appreciated.

    Additional Data:
    Gun Info (about 2/3 of the way down the page):
    http://en.wikipedia.org/wiki/Dahlgren_gun
     
  2. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    https://www.boundless.com/physics/t...basic-equations-and-parabolic-path-226-10952/

    If you have the max range at a given elevation you can probably use the equation in "Parabolic Trajectory" to compute the velocity so long as you aren't concerned with aerodynamic drag.

    The equation for x and y position given angle of elevation, velocity, and gravitational acceleration is shown there. Unless I'm having a brain fart, you'll have to solve for u (velocity). Fortunately in your case since you want to know the muzzle velocity all you should have to do is set y to 0, set x to the distance the projectile goes, then solve for u.

    The equation with y set to 0 becomes:

    0 = tan(elevation) * range - g / ((2-u^2-cos(elevation)^2) * range^2)

    Rearranging and solving for u (velocity) gives this:
    http://quickmath.com/webMathematica3/quickmath/equations/solve/advanced.jsp#c=solve_advancedsolveequations&v1=0=tan(o)*x - g/(2-u^2*cos(o)^2) * x^2)&v2=u

    If I'm not making a mistake which I could very easily be doing, that would translate in English to:

    muzzle velocity = sqrt(2-(g*range)/tan(elevation)) / cos(elevation)

    I haven't tried this myself, so no guarantees it will work. It's very easy to make a mistake here. If it does work, you can be pretty sure the real muzzle velocity is higher than this because we're neglecting air resistance. At least you'd be in the ballpark.
     
  3. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Here you go. Drop this on a Unity object and see if the results seem in the right ballpark to you.

    Given:
    G (acceleration of gravity) = -9.81
    Elevation = 45 degrees
    Range = 10000 meters

    It produces:
    muzzleVelocity = 442.9492 meters per second
    muzzleVelocity = 1453.246 feet per second
    muzzleVelocity = 990.8508 miles per hour
    muzzleVelocity = 1594.617 km per hour
    muzzleVelocity = 1.455634 Mach (@ sea level assuming Mach 1 = 761.2 mph)


    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class MuzzleVelocity : MonoBehaviour
    6. {
    7.  
    8.     public float g = -9.81f;
    9.     public float elevationDegrees = 45;
    10.     public float range = 1000f;
    11.  
    12.     void Start()
    13.     {
    14.         float elevationRadians = elevationDegrees * Mathf.Deg2Rad;
    15.         float muzzleVelocity = Mathf.Sqrt(2 - (g * range) / Mathf.Tan(elevationRadians)) / Mathf.Cos(elevationRadians);
    16.  
    17.         print("muzzleVelocity = " + muzzleVelocity + " meters per second");
    18.  
    19.         //Some other conversions:
    20.         print("muzzleVelocity = " + muzzleVelocity * 3.28084f + " feet per second");
    21.         print("muzzleVelocity = " + muzzleVelocity * 2.23694f + " miles per hour");
    22.         print("muzzleVelocity = " + muzzleVelocity * 3.6f + " km per hour");
    23.         print("muzzleVelocity = " + muzzleVelocity / 304.3f + " Mach (@ sea level assuming Mach 1 = 761.2 mph");
    24.      
    25.     }
    26.  
     
    image28 and boddole like this.
  4. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Or try this one. This one doesn't print anything, it just outputs it to the inspector. Click play and you can change the numbers in the inspector while it's running to see what it does. Remember, there's no air resistance here. That complicates things a bit more.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class MuzzleVelocity : MonoBehaviour
    6. {
    7.  
    8.     public float g = -9.81f;
    9.     public float elevationDegrees = 45;
    10.     public float range = 1000f;
    11.  
    12.     public float metersPerSecond;
    13.     public float feetPerSecond;
    14.     public float milesPerHour;
    15.     public float kilometersPerHour;
    16.     public float mach;
    17.  
    18.     void Update()
    19.     {
    20.         float elevationRadians = elevationDegrees * Mathf.Deg2Rad;
    21.         float muzzleVelocity = Mathf.Sqrt(2 - (g * range) / Mathf.Tan(elevationRadians)) / Mathf.Cos(elevationRadians);
    22.  
    23.         metersPerSecond = muzzleVelocity;
    24.         feetPerSecond = muzzleVelocity * 3.28084f;
    25.         milesPerHour = muzzleVelocity * 2.23694f;
    26.         kilometersPerHour = muzzleVelocity * 3.6f;
    27.         mach = muzzleVelocity / 304.3f;
    28.     }
    29. }
    30.  
     
    image28 and boddole like this.
  5. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    You're welcome. :rolleyes:
     
  6. boddole

    boddole

    Joined:
    Sep 18, 2013
    Posts:
    35
    Hey Todd, I know its a bit late...but I just saw this link (I put it in the wrong folder.....brilliant I know). I eventually found http://calculator.tutorvista.com/projectile-motion-calculator.html and it ends up giving ~313 m/s (or about a 41% difference from your calculations, but, I might be using it incorrectly). Either way, thank you for the effort.
     
  7. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,079
    Sure thing. Good luck. :)