[Test] public void GeodeticBearings() { TestCoords( (idx, from, to) => { double bearing = Geodetic.BearingDegrees(from, to); Assert.AreEqual(coords[idx, 3], bearing, 0.01, $"degrees for index {idx}"); double radians = Geodetic.BearingRadians(from, to); Assert.AreEqual(coords[idx, 3], Trig.ToDegrees(radians), 0.01, $"radians for index {idx}"); }); }
[Test] public void GeodeticDestination() { TestCoords( (idx, from, to) => { double kmApart = Geodetic.Kilometres(from, to); double bearing = Geodetic.BearingDegrees(from, to); var destination = Geodetic.Destination(start: from, distanceKm: kmApart, bearingDegrees: bearing); Assert.IsTrue(to.Equals(destination)); }); }
[Test] public void Example() { //- Generate coordinate structs in decimal degrees var from = Geodetic.Coords(latitude: -27.46850, longitude: 151.94379); //- or radians var to = Geodetic.Coords(latitude: -0.47941664, longitude: 2.65191906, radians: true); //- The calculations below don't need to know which form is used. We can always convert it ourselves from = from.ToRadians(); to = to.ToDegrees(); //- Now we have two coordinates we can calculate how far apart they are double metresApart = Geodetic.Kilometres(from, to) * 1000; //- or use the human readable form which will use meters or km as needed string distanceApart = Geodetic.DistanceBetween(from, to); //- Now we have distance, what direction do we need to travel double bearing = Geodetic.BearingDegrees(from, to); //- and in radians double radians = Geodetic.BearingRadians(from, to); //- But what if we know the direction and distance to an object var destination = Geodetic.Destination(start: from, distanceKm: metresApart * 1000, bearingDegrees: bearing); }