Blog Entry © Friday, January 16, 2026, by James Pate Williams, Jr., Another Update of My Iowa Class Battleship Artillery Exterior Ballistics Application

Blog Entry © Wednesday, January 14, 2026, by James Pate Williams, Jr. Curvature of the Earth Table

// CurvatureOfTheEarth.cpp : Defines the entry point for the application.
//

#include "pch.h"
#include "framework.h"
#include "CurvatureOfTheEarth.h"
#include "GreatCircleDistance.h"
#include "Vincenty.h"

#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst;                                // current instance
WCHAR szTitle[MAX_LOADSTRING];                  // The title bar text
WCHAR szWindowClass[MAX_LOADSTRING];            // the main window class name
WCHAR line[128];                                // general purpose buffer
std::wstring outputText;                        // output wide character text

// Forward declarations of functions included in this code module:
ATOM                MyRegisterClass(HINSTANCE hInstance);
BOOL                InitInstance(HINSTANCE, int);
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK    TableDialog(HWND, UINT, WPARAM, LPARAM);

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    // TODO: Place code here.

    // Initialize global strings
    LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
    LoadStringW(hInstance, IDC_CURVATUREOFTHEEARTH, szWindowClass, MAX_LOADSTRING);
    MyRegisterClass(hInstance);

    // Perform application initialization:
    if (!InitInstance (hInstance, nCmdShow))
    {
        return FALSE;
    }

    HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_CURVATUREOFTHEEARTH));

    MSG msg;

    // Main message loop:
    while (GetMessage(&msg, nullptr, 0, 0))
    {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    return (int) msg.wParam;
}

//
//  FUNCTION: MyRegisterClass()
//
//  PURPOSE: Registers the window class.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
    WNDCLASSEXW wcex = { 0 };

    wcex.cbSize = sizeof(WNDCLASSEX);

    wcex.style          = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = WndProc;
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = hInstance;
    wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_CURVATUREOFTHEEARTH));
    wcex.hCursor        = LoadCursor(nullptr, IDC_ARROW);
    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName   = MAKEINTRESOURCEW(IDC_CURVATUREOFTHEEARTH);
    wcex.lpszClassName  = szWindowClass;
    wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

    return RegisterClassExW(&wcex);
}

//
//   FUNCTION: InitInstance(HINSTANCE, int)
//
//   PURPOSE: Saves instance handle and creates main window
//
//   COMMENTS:
//
//        In this function, we save the instance handle in a global variable and
//        create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
   hInst = hInstance; // Store instance handle in our global variable

   HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);

   if (!hWnd)
   {
      return FALSE;
   }

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}

//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE: Processes messages for the main window.
//
//  WM_COMMAND  - process the application menu
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_CREATE:
        DialogBox(hInst, MAKEINTRESOURCE(IDD_TABLE_DIALOG), hWnd, TableDialog);
        break;
    case WM_COMMAND:
        {
            int wmId = LOWORD(wParam);
            // Parse the menu selections:
            switch (wmId)
            {
            case IDM_ABOUT:
                DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
                break;
            case IDM_EXIT:
                DestroyWindow(hWnd);
                break;
            default:
                return DefWindowProc(hWnd, message, wParam, lParam);
            }
        }
        break;
    case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hWnd, &ps);
            // TODO: Add any drawing code that uses hdc here...
            EndPaint(hWnd, &ps);
        }
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}

// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    UNREFERENCED_PARAMETER(lParam);
    switch (message)
    {
    case WM_INITDIALOG:
        return (INT_PTR)TRUE;

    case WM_COMMAND:
        if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
        {
            EndDialog(hDlg, LOWORD(wParam));
            return (INT_PTR)TRUE;
        }
        break;
    }
    return (INT_PTR)FALSE;
}

INT_PTR CALLBACK TableDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    UNREFERENCED_PARAMETER(lParam);
    static double deltaTime = 0;
    static int height = 20, width = 80;
    static size_t delta = 0;
    static HFONT hFont = NULL;
    static HWND hEditMultiline = NULL;
    static GreatCircleDistance gcd;
    static Vincenty vincenty;

    switch (message)
    {
    case WM_INITDIALOG:
        hFont = CreateFont(
            -MulDiv(7, GetDeviceCaps(GetDC(hDlg), LOGPIXELSY), 72),
            0, 0, 0, FW_BOLD, FALSE, FALSE, FALSE,
            DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
            CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
            FIXED_PITCH | FF_MODERN,
            TEXT("Courier New")
        );

        hEditMultiline = CreateWindowEx(
            WS_EX_CLIENTEDGE,                       // Extended style for sunken border
            TEXT("EDIT"),                           // Class name
            TEXT(""),                               // Initial text (can be blank)
            WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_READONLY,
            10, 0, 10 * width, 30 * height,         // Position and size
            hDlg,                                   // Parent window handle
            (HMENU)IDC_EDIT_MULTILINE,              // Unique control ID
            hInst,                                  // Application instance
            NULL                                    // Extra parameter
        );

        SendMessage(hEditMultiline, WM_SETFONT, (WPARAM)hFont, TRUE);
        return (INT_PTR)TRUE;

    case WM_COMMAND:
        if (LOWORD(wParam) == IDCANCEL)
        {
            EndDialog(hDlg, LOWORD(wParam));
            return (INT_PTR)TRUE;
        }

        if (LOWORD(wParam) == IDC_BUTTON_COMPUTE)
        {
            outputText += L"Range in Yards Versus Curvature of the Earth in Feet\r\n\r\n";
            outputText += L"Yards\t 0\t 100\t 200\t 300\t 400\t 500\t 600\t 700\t 800\t 900\r\n";
                
            for (double row = 1000.0; row <= 40000.0; row += 1000.0)
            {
                swprintf_s(line, L"%6.1lf\t", row);
                outputText += line;

                for (double col = 0.0; col <= 900.0; col += 100.0)
                {
                    double r = row + col;
                    double distance = 3.0 * gcd.Interpolate(r);

                    swprintf_s(line, L"%4.1lf\t", distance);
                    outputText += line;
                }

                outputText += L"\r\n";
            }

            outputText += L"Yards\t 0\t 100\t 200\t 300\t 400\t 500\t 600\t 700\t 800\t 900\r\n";
            SetWindowText(hEditMultiline, outputText.c_str());
            return (INT_PTR)TRUE;
        }
    }

    return (INT_PTR)FALSE;
}

#pragma once
#include "Vincenty.h"

struct PointRaR
{
    double ra;   // curvature of the Earth correction in yards
    double r;    // flat Earth distance (chord) in yards

    PointRaR(double ra, double r)
    {
        this->ra = ra;
        this->r = r;
    }
};

class GreatCircleDistance
{

private:

    Vincenty vincenty;
    std::vector<PointRaR> pts;

    bool binarySearch(double x, int& lt, int& rt);

public:

    friend int compare(
        const PointRaR& lt,
        const PointRaR& rt)
    {
        if (lt.r < rt.r)
            return -1;
        if (lt.r > rt.r)
            return +1;

        return 0;
    };

    // R is in yards, returns in yards
    // Curvature of the Earth correction

    double Interpolate(double R);

    // construction of the curvature of the Earth table

    GreatCircleDistance();
};

#pragma once

class Vincenty
{

public:

    static double Re; // Radius of Earth in meters
    double deltaSigma(
        double phi1, double lambda1,
        double phi2, double lambda2);
    double distance(
        double phi1, double lambda1,
        double phi2, double lambda2);
    double distanceConstantLambda(
        double phi1, double phi2);
    double distanceConstantXY(double z);
    double x(double phi, double lambda);
    double y(double phi, double lambda);
    double z(double phi);
    double phi(double z);
    double lambda(double x, double y);
};

#include "pch.h"
#include "GreatCircleDistance.h"

bool GreatCircleDistance::binarySearch(
    double x, int& lt, int& rt)
{
    int n = static_cast<int>(pts.size()), L = 0, M, R = n - 1;

Label10:

    if (x == pts[L].r)
    {
        lt = rt = L;
        return true;
    }

    if (x == pts[R].r)
    {
        lt = rt = R;
        return true;
    }

    if (x > pts[L].r && x < pts[R].r && R - L == 1)
    {
        lt = L;
        rt = R;
        return true;
    }

    if (x > pts[L].r && x < pts[R].r)
    {
        M = (L + R) / 2;

        if (x > pts[M].r)
        {
            L = M;
            goto Label10;
        }

        if (x < pts[M].r)
        {
            R = M;
            goto Label10;
        }
    }

    lt = rt = -1;
    return false;
}

double GreatCircleDistance::Interpolate(double R)
{
    int lt, rt;

    if (binarySearch(R, lt, rt))
    {
        double x0 = pts[lt].ra, x1 = pts[rt].ra;
        double y0 = pts[lt].r, y1 = pts[rt].r;
        double deltaX = x1 - x0, deltaY = y1 - y0;
        double ra = deltaX * (R - y0) / deltaY + x0;

        return ra;
    }

    return -1.0;
}

GreatCircleDistance::GreatCircleDistance()
{
    double deltaPhi = 0.000001, phi1 = 0.0, phi2 = deltaPhi, delta;
    double deltaRa, d0 = vincenty.z(phi1), d1, r, ra;
    int cnt = 0;

    pts.push_back(PointRaR(0.0, 0.0));

    while (cnt < 10000)
    {
        d1 = vincenty.z(phi2);

        if (d0 >= d1)
        {
            delta = d0 - d1;
            deltaRa = d0 * d0 - d1 * d1;
        }

        else
        {
            delta = d1 - d0;
            deltaRa = d1 * d1 - d0 * d0;
        }

        r = delta;
        ra = sqrt(deltaRa);
        ra = r >= ra ? r - ra : ra - r;
        pts.push_back(PointRaR(1.0936 * r, 1.0936 * ra));
        phi2 += deltaPhi;
        cnt++;
    }
}

#include "pch.h"
#include "Vincenty.h"

double Vincenty::Re = 6378137.0;	// radius of Earth in meters

double Vincenty::deltaSigma(
    double phi1, double lambda1,
    double phi2, double lambda2)
{
    double deltaPhi = phi1 - phi2, deltaLambda = lambda1 - lambda2;
    double cosPhi1 = cos(phi1), cosPhi2 = cos(phi2);
    double sinPhi1 = sin(phi1), sinPhi2 = sin(phi2);
    double cosDeltaLambda = cos(deltaLambda), sinDeltaLambda = sin(deltaLambda);
    double numer1 = cosPhi2 * sinDeltaLambda;
    double numer2 = cosPhi1 * sinPhi2 - sinPhi1 * cosPhi2 * cosDeltaLambda;
    double numer = sqrt(numer1 * numer1 + numer2 * numer2);
    double denom = sinPhi1 * sinPhi2 + cosPhi1 * cosPhi2 * cosDeltaLambda;

    return atan2(numer, denom);
}

double Vincenty::distance(
    double phi1, double lambda1,
    double phi2, double lambda2)
{
    return Re * deltaSigma(phi1, lambda1, phi2, lambda2);
}

double Vincenty::distanceConstantLambda(
    double phi1, double phi2)
{
    return Re * distance(phi1, 0.0, phi2, 0.0);
}

double Vincenty::distanceConstantXY(double z)
{
    return Re * distance(phi(0.0), 0.0, phi(z), 0.0);
}

double Vincenty::x(double phi, double lambda)
{
    return Re * sin(phi) * cos(lambda);
}

double Vincenty::y(double phi, double lambda)
{
    return Re * sin(phi) * sin(lambda);
}

double Vincenty::z(double phi)
{
    return Re * cos(phi);
}

double Vincenty::phi(double z)
{
    return acos(z / sqrt(Re));
}

double Vincenty::lambda(double x, double y)
{
    return asin(y / sqrt(x * x + y * y));
}

Blog Entry © Thursday, January 8, 2026, by James Pate Williams, Jr., Revised United States Navy Fast Battleship Iowa Class Artillery Ballistics Tables

Blog Entry © Thursday, January 1, 2026, by James Pate Williams, Jr., Win32 C/C++ Fast Battleship Class Iowa Ballistics Calculator (BB-61 Iowa, BB-62 New Jersey, BB-63 Missouri, BB-64 Wisconsin)

Blog Entry © Thursday, June 5, 2025, by James Pate Williams, Jr., Analytic, Numeric, and Siacci’s Method for Solving Ballistic Trajectory Problems (Point-Mass Projectile Motion)

Blog Entry (c) Monday, June 2, 2025, Exercises from “Exterior ballistics, 1935” by James Pate Williams, Jr.

Below are some Exercises from the textbook Exterior ballistics, 1935 by former Lieutenant Commander Ernest Edward Herrman of the United States Navy Naval Academy in Annapolis, Maryland, see Chapter Four:

Density         Published Density

1.183473 1.183472
1.306584 1.306582
1.202410 1.202408
0.694163 0.694162

Exercises from Exterior ballistics, 1935
By Lieutenant Commander Ernest Edward Herrmann
Exercise 1 Page 41

Book Mine

0.157100 0.157563
0.492680 0.492810
0.517340 0.517829
0.675240 0.675580
0.844370 0.844597
1.018110 1.018197
1.014010 1.014027
1.094820 1.094910

Percentage Differences Exercise 1 Page 41

Percentage Difference [1] = 0.294283%
Percentage Difference [2] = 0.026383%
Percentage Difference [3] = 0.094477%
Percentage Difference [4] = 0.050340%
Percentage Difference [5] = 0.026880%
Percentage Difference [6] = 0.008545%
Percentage Difference [7] = 0.001676%
Percentage Difference [8] = 0.008220%

Three Altitude Related Density Calculations
Rho1 is from Exterior ballistics, 1935
Rho2 is from NASA
Rho3 is from Wikipedia

h ft Rho1 SI Rho2 SI Rho3

0 1.000000 1.226614 1.208993
1000 0.968902 1.215727 1.174010
2000 0.938772 1.204914 1.139806
3000 0.909578 1.194175 1.106369
4000 0.881292 1.183510 1.073689
5000 0.853886 1.172917 1.041752
6000 0.827332 1.162397 1.010547
7000 0.801604 1.151949 0.980062
8000 0.776676 1.141574 0.950286

Three Altitude Related Ballistic Density Calculations
Rho1 is from Exterior ballistics, 1935
Rho2 is from NASA
Rho3 is from Wikipedia
STP = Temperature = 59 F Pressure = 29.53 Humidity = 78%

Temp Press h ft Rho1 SI Rho2 SI Rho3

65 29.60 1000 0.968902 1.203134 1.161848
85 29.75 18000 0.566291 0.992154 0.656245
57 30.25 8000 0.776676 1.174418 0.977626
69 29.80 13000 0.663193 1.077573 0.801819
32 30.15 15000 0.622587 1.157366 0.822138

Exercise 3 Problems 1 - 4 m below means mine
Ra Ram are the Mayevski Retardations
Rf Rfm are the forces of Air Resistence
V Vm are the Applicable Velocities

Ra Ram Rf Rfm V Vm

567.20 567.22 229.28 229.19 2626 2626
323.85 323.86 503.50 503.29 3114 3114
91.58 91.58 2477.50 2476.50 2862 2862
62.02 62.02 4049.40 4047.83 2584 2584

Exercise 4 - Problems 1 to 5
Ra Ram BC Density

293.82 306.84 3.110358 0.989712
160.92 185.47 4.737834 1.009200
119.06 123.90 6.991926 0.952504
73.58 84.81 10.328256 0.987977
60.52 69.59 12.442559 1.080786

Exercise 5 - Problems 1 to 4
Ra Gv i-book i-mine

511.76 803.10 1.001500 0.959553
334.04 1071.14 0.602720 0.578983
90.62 922.06 0.601870 0.577421
57.30 799.71 0.616870 0.593688

Test Case from Exterior ballistics, 1935
Temperature 84 F Pressure 29.90 In Hg
Density SI = 0.959428 Book Density = 0.960
Altitude 18,000 Feet
Density SI = 0.999439 Book Density = 0.991

The differences above are probably due to the fact that Lieutenant Commander Herrmann used logarithms and logarithm tables and perhaps a slide-rule. I use double precision C/C++ real numbers.

Blog Entry © Saturday, May 31, 2025, Air Density and Ballistic Density Computations by James Pate Williams, Jr.

Online references: https://www.grc.nasa.gov/WWW/K-12/airplane/atmosmet.html and https://www.nist.gov/system/files/documents/calibrations/metv29i1p67-2.pdf

Density         Published Density

1.183473 1.183472
1.306584 1.306582
1.202410 1.202408
0.694163 0.694162

Exercises from Exterior ballistics, 1935
By Lieutenant Commander Ernest Edward Herrmann
Percentage Differences Exercise 1 Page 41

Percentage Difference [1] = 0.294283%
Percentage Difference [2] = 0.026383%
Percentage Difference [3] = 0.094477%
Percentage Difference [4] = 0.050340%
Percentage Difference [5] = 0.026880%
Percentage Difference [6] = 0.008545%
Percentage Difference [7] = 0.001676%
Percentage Difference [8] = 0.008220%

Three Altitude Related Density Calculations
Rho1 is from Exterior ballistics, 1935
Rho2 is from NASA
Rho3 is from Wikipedia

h ft Rho1 SI Rho2 SI Rho3

0 1.000000 1.226614 1.208993
1000 0.968902 1.215727 1.174010
2000 0.938772 1.204914 1.139806
3000 0.909578 1.194175 1.106369
4000 0.881292 1.183510 1.073689
5000 0.853886 1.172917 1.041752
6000 0.827332 1.162397 1.010547
7000 0.801604 1.151949 0.980062
8000 0.776676 1.141574 0.950286

Three Altitude Related Ballistic Density Calculations
Rho1 is from Exterior ballistics, 1935
Rho2 is from NASA Rho3 is from Wikipedia
STP = Temperature = 59 F Pressure = 29.53 Humidity = 78%

Temp Press h ft Rho1 SI Rho2 SI Rho3

65 29.60 1000 0.968902 1.203134 1.161848
85 29.75 18000 0.566291 0.992155 0.656245
57 30.25 8000 0.776676 1.174418 0.977626
69 29.80 13000 0.663193 1.077573 0.801819
32 30.15 15000 0.622587 1.157366 0.822138

Test Case from Exterior ballistics, 1935
Temperature 84 F Pressure 29.90 In Hg
Density SI = 0.959428 Book Density = 0.960
Altitude 18,000 Feet
Density SI = 0.999439 Book Density = 0.991

Blog Entry © Friday, May 30, 2025, Ballistic Coefficient Exercises from Exterior ballistics, 1935 Written by Ernest Edward Herrmann, C/C++ Code by James Pate Williams, Jr., BA, BS, Master of Software Engineering, PhD Computer Science

#include <iomanip>
#include <iostream>

double BookAnswers[] = {
    0.15710, 0.49268, 0.51734, 0.67524,
    0.84437, 1.01811, 1.01401, 1.09482 };
double MyAnswers[] = {
    0.157563, 0.492810, 0.517829, 0.675580,
    0.844597, 1.018197, 1.014027, 1.094910 };
double PD[8];

int main()
{
    std::cout << "Percentage Differences" << std::endl;
    std::cout << std::fixed << std::setprecision(6);

    for (int i = 0; i < 8; i++)
    {
        PD[i] = 100.0 * fabs(BookAnswers[i] - MyAnswers[i]) /
            (0.5 * (BookAnswers[i] + MyAnswers[i]));
        std::cout << "Percentage Difference [" << i + 1 << "] = ";
        std::cout << PD[i] << '%' << std::endl;
    }
}

Blog Entry © Wednesday, May 28, 2025, More C/C++ Siacci Method Ballistic Screenshots by James Pate Williams, Jr., BA, BS, MSWE, PhD