MCDRAG: When 1974 BASIC Meets Modern WebAssembly
Back in December 1974, R.L. McCoy developed MCDRAG—an algorithm for estimating drag coefficients of axisymmetric projectiles. Originally written in BASIC and designed to run on mainframes and early microcomputers, this pioneering work provided engineers with a way to quickly estimate aerodynamic properties without expensive wind tunnel testing. Today, I'm bringing this piece of ballistics history to your browser through a Rust implementation compiled to WebAssembly.
The Original: Computing Ballistics When Memory Was Measured in Kilobytes
The original MCDRAG program is a fascinating artifact of 1970s scientific computing. Written in structured BASIC with line numbers, it implements sophisticated aerodynamic calculations using only basic mathematical operations available on computers of that era. The program calculates drag coefficients across Mach numbers from 0.5 to 5.0, breaking down the total drag into components:
-
CD0: Total drag coefficient
-
CDH: Head drag coefficient
-
CDSF: Skin friction drag coefficient
-
CDBND: Rotating band drag coefficient
-
CDBT: Boattail drag coefficient
-
CDB: Base drag coefficient
-
PB/PINF: Base pressure ratio
What's remarkable is how McCoy managed to encode complex aerodynamic relationships—including transonic effects, boundary layer transitions, and base pressure corrections—in just 260 lines of BASIC code. The program even includes diagnostic warnings for problematic geometries, alerting users when their projectile design might produce unreliable results.
The Algorithm: Physics Encoded in Code
MCDRAG uses semi-empirical methods to estimate drag, combining theoretical aerodynamics with experimental correlations. The algorithm accounts for:
- Flow Regime Transitions: Different calculation methods for subsonic, transonic, and supersonic speeds
- Boundary Layer Effects: Three models (Laminar/Laminar, Laminar/Turbulent, Turbulent/Turbulent)
- Geometric Complexity: Handles nose shapes (via the RT/R parameter), boattails, meplats, and rotating bands
- Reynolds Number Effects: Calculates skin friction based on flow conditions and projectile scale
The core innovation was providing reasonable drag estimates across the entire speed range relevant to ballistics—from subsonic artillery shells to hypersonic tank rounds—using a unified computational framework.
The Modern Port: Rust + WebAssembly
My Rust implementation preserves the original algorithm's mathematical fidelity while bringing modern software engineering practices:
#[derive(Debug, Clone, Copy)] enum BoundaryLayer { LaminarLaminar, LaminarTurbulent, TurbulentTurbulent, } impl ProjectileInput { fn calculate_drag_coefficients(&self) -> Vec<DragCoefficients> { // Implementation follows McCoy's original algorithm // but with type safety and modern error handling } }
The Rust version offers several advantages:
-
Type Safety: Enum types for boundary layers prevent invalid inputs
-
Memory Safety: No buffer overflows or undefined behavior
-
Performance: Native performance in browsers via WebAssembly
-
Modularity: Clean separation between core calculations and UI
Try It Yourself: Interactive MCDRAG Terminal
Below is a fully functional MCDRAG calculator running entirely in your browser. No server required—all calculations happen locally using WebAssembly.
Using the Terminal
The terminal above provides a faithful recreation of the original MCDRAG experience with modern conveniences:
-
start: Begin entering projectile parameters
-
example: Load a pre-configured 7.62mm NATO M80 Ball example
-
clear: Clear the terminal display
-
help: Show available commands
The calculator will prompt you for:
- Reference diameter (in millimeters)
- Total length (in calibers - multiples of diameter)
- Nose length (in calibers)
- RT/R headshape parameter (ratio of tangent radius to actual radius)
- Boattail length (in calibers)
- Base diameter (in calibers)
- Meplat diameter (in calibers)
- Rotating band diameter (in calibers)
- Center of gravity location (optional, in calibers from nose)
- Boundary layer code (L/L, L/T, or T/T)
- Projectile identification name
Historical Context: Why MCDRAG Matters
MCDRAG represents a pivotal moment in computational ballistics. Before its development, engineers relied on:
-
Expensive wind tunnel testing for each design iteration
-
Simplified point-mass models that ignored aerodynamic details
-
Interpolation from limited experimental data tables
McCoy's work democratized aerodynamic analysis, allowing engineers with access to even modest computing resources to explore design spaces rapidly. The algorithm's influence extends beyond its direct use—it established patterns for semi-empirical modeling that influenced subsequent ballistics software development.
Technical Deep Dive: The Implementation
The Rust implementation leverages several modern programming techniques while maintaining algorithmic fidelity:
Type Safety and Domain Modeling
#[derive(Debug, Serialize, Deserialize)] pub struct ProjectileInput { pub ref_diameter: f64, // D1 - Reference diameter (mm) pub total_length: f64, // L1 - Total length (calibers) pub nose_length: f64, // L2 - Nose length (calibers) pub rt_r: f64, // R1 - RT/R headshape parameter pub boattail_length: f64, // L3 - Boattail length (calibers) pub base_diameter: f64, // D2 - Base diameter (calibers) pub meplat_diameter: f64, // D3 - Meplat diameter (calibers) pub band_diameter: f64, // D4 - Rotating band diameter (calibers) pub cg_location: f64, // X1 - Center of gravity location pub boundary_layer: BoundaryLayer, pub identification: String, }
WebAssembly Integration
The wasm-bindgen
crate provides seamless JavaScript interop:
#[wasm_bindgen] impl McDragCalculator { #[wasm_bindgen(constructor)] pub fn new() -> McDragCalculator { McDragCalculator { current_input: None, } } #[wasm_bindgen] pub fn calculate(&self) -> Result<String, JsValue> { // Perform calculations and return JSON results } }
Performance Optimizations
While maintaining mathematical accuracy, the Rust version includes several optimizations:
-
Pre-computed constants replace repeated calculations
-
Efficient memory layout reduces cache misses
-
SIMD-friendly data structures (when compiled for native targets)
Applications and Extensions
Beyond its historical interest, MCDRAG remains useful for:
-
Educational purposes: Understanding fundamental aerodynamic concepts
-
Initial design estimates: Quick sanity checks before detailed CFD analysis
-
Embedded systems: The algorithm's simplicity suits resource-constrained environments
-
Machine learning features: MCDRAG outputs can serve as engineered features for ML models
Open Source and Future Development
The complete source code for both the Rust library and web interface is available on GitHub. The project is structured to support multiple use cases:
- Standalone CLI: Native binary for command-line use
- Library: Rust crate for integration into larger projects
- WebAssembly module: Browser-ready calculations
- FFI bindings: C-compatible interface for other languages
Future enhancements under consideration:
- GPU acceleration for batch calculations
- Integration with modern CFD validation data
- Extended parameter ranges for hypersonic applications
- Machine learning augmentation for uncertainty quantification
Conclusion: Bridging Eras
MCDRAG exemplifies how good engineering transcends its original context. What began as a BASIC program for 1970s mainframes now runs in your browser at speeds McCoy could hardly have imagined. Yet the core algorithm—the physics and mathematics—remains unchanged, a testament to the fundamental soundness of the approach.
This project demonstrates that preserving and modernizing legacy scientific software isn't just about nostalgia. These programs encode decades of domain expertise and validated methodologies. By bringing them forward with modern tools and platforms, we make this knowledge accessible to new generations of engineers and researchers.
Whether you're a ballistics engineer needing quick estimates, a student learning about aerodynamics, or a programmer interested in scientific computing history, I hope this implementation of MCDRAG proves both useful and inspiring. The terminal above isn't just a calculator—it's a bridge between computing eras, showing how far we've come while honoring where we started.
References and Further Reading
-
McCoy, R.L. (1974). "MCDRAG - A Computer Program for Estimating the Drag Coefficients of Projectiles." Technical Report, U.S. Army Ballistic Research Laboratory.
-
McCoy, R.L. (1999). "Modern Exterior Ballistics: The Launch and Flight Dynamics of Symmetric Projectiles." Schiffer Military History.
-
Carlucci, D.E., & Jacobson, S.S. (2018). "Ballistics: Theory and Design of Guns and Ammunition" (3rd ed.). CRC Press.
The MCDRAG algorithm is in the public domain. The Rust implementation and web interface are released under the BSD 3-Clause License.