NavLab examples

This page illustrates implementations of the examples from www.navlab.net/nvector. Values are chosen to match those used in nvector.readthedocs.org.

Example 1: A and B to delta

    import LatLon from 'latlon-nvector-ellipsoidal.js';

    var a = new LatLon(1, 2, 3); // defaults to WGS-84
    var b = new LatLon(4, 5, 6);
    var delta = a.deltaTo(b);   // [N:331730.863,E:332998.501,D:17398.304]
    var dist = delta.length;    // 470357.384 m
    var brng = delta.bearing;   // 45.109°
    var elev = delta.elevation; // -2.1198°

Example 2: B and delta to C*

    import LatLon, { Nvector, Ned } from 'latlon-nvector-ellipsoidal.js';

    var n = new Nvector(1, 2, 3, 400, LatLon.datums.WGS72); // [0.267,0.535,0.802,400.000]
    var b = n.toLatLon();                                   // 53.301°N, 063.435°E +400.000m
    var delta = new Ned(3000, 2000, 100);                   // [N:3000,E:2000,D:100]
    var c = b.destinationPoint(delta);                      // 53.328°N, 063.465°E +299.138m

Example 3: ECEF-vector to geodetic latitude

    import LatLon, { Cartesian } from 'latlon-nvector-ellipsoidal.js';

    var c = new Cartesian(0.9*6371e3, -1.0*6371e3, 1.1*6371e3);
    var p = c.toLatLon(); // 39.379°N, 048.013°W +4702059.834m

Example 4: Geodetic latitude to ECEF-vector

    import LatLon, { Cartesian } from 'latlon-nvector-ellipsoidal.js';

    var p = new LatLon(1, 2, 3);
    var c = p.toCartesian(); // [6373290.277,222560.201,110568.827]

Example 5: Surface distance

    import LatLon from 'latlon-nvector-spherical.js';

    var a = new LatLon(88, 0);
    var b = new LatLon(89, -170);
    var dist = a.distanceTo(b); // 332.5 km

Example 7: Mean position

    import LatLon from 'latlon-nvector-spherical.js';

    var points = [
        new LatLon(90,   0),
        new LatLon(60,  10),
        new LatLon(50, -20),
    ];
    var mean = LatLon.meanOf(points); // 67.2362°N, 006.9175°W

Example 8: A and azimuth/distance to B

    import LatLon from 'latlon-nvector-spherical.js';

    var a = new LatLon(80, -90);
    var b = a.destinationPoint(1000, 200); // 79.9915°N, 090.0177°W

Example 9: Intersection of two paths

    import LatLon from 'latlon-nvector-spherical.js';

    var a1 = new LatLon(10, 20);
    var a2 = new LatLon(30, 40);
    var b1 = new LatLon(50, 60);
    var b2 = new LatLon(70, 80);
    var c = LatLon.intersection(a1, a2, b1, b2); // 40.3186°N, 055.9019°E

Example 10: Cross track distance

    import LatLon from 'latlon-nvector-spherical.js';

    var a1 = new LatLon( 0, 0);
    var a2 = new LatLon(10, 0);
    var b = new LatLon(1, 0.1);
    var c = b.crossTrackDistanceTo(a1, a2); // 11.12 km