All Projects → vahancho → erkir

vahancho / erkir

Licence: other
Երկիր (Erkir) - a C++ library for geodesic and trigonometric calculations

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to erkir

Geokit
Geo-Toolkit for PHP.
Stars: ✭ 223 (+757.69%)
Mutual labels:  geometry, distance, geography
geodesy-php
Geodesy PHP - Port of some known geodesic/math functions for getting distance from a known point A to a known point B given their coordinates. It also supports conversion between units of length, Polar position to Cartesian coordinates, and different Reference Datums.
Stars: ✭ 26 (+0%)
Mutual labels:  distance, geodesy, distance-calculation
TriangleMeshDistance
Header only, single file, simple and efficient C++11 library to compute the signed distance function (SDF) to a triangle mesh
Stars: ✭ 55 (+111.54%)
Mutual labels:  geometry, distance
Three Mesh Bvh
A BVH implementation to speed up raycasting against three.js meshes.
Stars: ✭ 302 (+1061.54%)
Mutual labels:  geometry, distance
Graphical Debugging
GraphicalDebugging extension for Visual Studio
Stars: ✭ 88 (+238.46%)
Mutual labels:  geometry, stl
Textdistance
Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.
Stars: ✭ 2,575 (+9803.85%)
Mutual labels:  distance, distance-calculation
Haversine
Calculate the distance bewteen 2 points on Earth
Stars: ✭ 166 (+538.46%)
Mutual labels:  distance, earth
Pas Coogeo
Pas-CooGeo is coordinate geometry library for Pascal.
Stars: ✭ 25 (-3.85%)
Mutual labels:  geometry, distance
laravel-geoly
Perform fast and efficient radius searches on your Laravel Eloquent models.
Stars: ✭ 25 (-3.85%)
Mutual labels:  distance, distance-calculation
Cheap Ruler Go
📏 cheapruler in Go: fast geodesic measurements
Stars: ✭ 176 (+576.92%)
Mutual labels:  geometry, distance
Microsoft.SqlServer.Types
a .NET Standard implementation of the spatial types in `Microsoft.SqlServer.Types`
Stars: ✭ 64 (+146.15%)
Mutual labels:  geometry, geography
Geocalc
Helper classes to calculate Earth distances, bearing, etc.
Stars: ✭ 88 (+238.46%)
Mutual labels:  distance, earth
Geolib
Zero dependency library to provide some basic geo functions
Stars: ✭ 3,675 (+14034.62%)
Mutual labels:  distance, geography
BodyParts3D
Clone of the BodyParts3D/Anatomography 3D model files
Stars: ✭ 32 (+23.08%)
Mutual labels:  geometry, stl
Vincenty-Excel
Thaddeus Vincenty's Direct and Inverse formulae for geodesic calculations in Excel (distance, azimuth, latitude, longitude).
Stars: ✭ 29 (+11.54%)
Mutual labels:  distance, geodesy
Geom
2D/3D geometry toolkit for Clojure/Clojurescript
Stars: ✭ 759 (+2819.23%)
Mutual labels:  geometry, stl
blender-importer-unity
A tool to fix orientation issues from Blender to Unity
Stars: ✭ 23 (-11.54%)
Mutual labels:  coordinate-systems, coordinates
dist
🗺️ Python/C API extension module that computes distance between two coordinates on the world map
Stars: ✭ 13 (-50%)
Mutual labels:  distance, coordinates
Doctrine Postgis
Spatial and Geographic Data with PostGIS and Doctrine.
Stars: ✭ 161 (+519.23%)
Mutual labels:  geometry, geography
wkb-parser
Well-known binary (WKB) Parser.
Stars: ✭ 69 (+165.38%)
Mutual labels:  geometry, geography

Երկիր (Erkir) - a C++ library for geodesic and trigonometric calculations

Erkir (armenian: Երկիր, means Earth) - is inspired by and based on the great work of Chris Veness, the owner of the Geodesy functions project - provides a set of comprehensive API for geodesic and trigonometric calculations. I would call it a C++ port of JavaScript functions provided by the mentioned Chris Veness' project, however I designed the library to be more object oriented. Thus the code is organized a little bit differently, but the implementation itself is preserved.

Latest release Build Status Build status codecov

Prerequisites

There are no special requirements and dependencies except C++11 compliant compiler. The class is tested with gcc 4.8.4 and MSVC 15.x (Visual Studio 2017). The library is written with pure STL without any third party dependencies. For more details see the CI badges (Travis CI & AppVeyor CI) above.

Installation

No installation required. Just incorporate header files from the include/ and source files from src/ directories in your project and compile them. All library classes are in erkir namespace.

The API

The code is virtually split into three domains (namespaces) that represent spherical and ellipsoidal geodetic coordinates and cartesian (x/y/z) for geocentric ones: erkir::spherical, erkir::ellipsoidal and erkir::cartesian correspondingly. Spherical Earth model based calculations are accurate enough for most cases, however in order to gain more precise measurements use erkir::ellipsoidal classes.

erkir::spherical::Point class implements geodetic point on the basis of a spherical earth (ignoring ellipsoidal effects). It uses formulae to calculate distances between two points (using haversine formula), initial bearing from a point, final bearing to a point, etc.

erkir::ellipsoidal::Point class represents geodetic point based on ellipsoidal earth model. It includes ellipsoid parameters and datums for different coordinate systems, and methods for converting between them and to Cartesian coordinates.

erkir::Vector3d implements 3-d vector manipulation routines. With this class you can perform basic operations with the vectors, such as calculate dot (scalar) product of two vectors, multiply vectors, add and subtract them.

erkir::cartesian::Point implements ECEF (earth-centered earth-fixed) geocentric cartesian (x/y/z) coordinates.

Usage Examples:

#include "sphericalpoint.h"
#include "ellipsoidalpoint.h"

int main(int argc, char **argv)
{
  // Calculate great-circle distance between two points.
  erkir::spherical::Point p1{ 52.205, 0.119 };
  erkir::spherical::Point p2{ 48.857, 2.351 };
  auto d = p1.distanceTo(p2); // 404.3 km
  
  // Get destination point by given distance (shortest) and bearing from start point.
  erkir::spherical::Point p3{ 51.4778, -0.0015 };
  auto dest = p3.destinationPoint(7794.0, 300.7); // 51.5135°N, 000.0983°W
  
  // Convert a point from one coordinates system to another.
  erkir::ellipsoidal::Point pWGS84(51.4778, -0.0016, ellipsoidal::Datum::Type::WGS84);
  auto pOSGB = pWGS84.toDatum(ellipsoidal::Datum::Type::OSGB36); // 51.4778°N, 000.0000°E

  // Convert to Cartesian coordinates.
  auto cartesian = pWGS84.toCartesianPoint();

  // Convert Cartesian point to a geodetic one.
  auto geoPoint = cartesian->toGeoPoint();

  return 0;
}

For more usage examples please refer to the unit tests at /test/test.cpp file.

Building and Testing

There are unit tests. You can find them in the test/ directory. To run them you have to build and run the test application. For doing that you must invoke the following commands from the terminal, assuming that compiler and environment are already configured:

Linux (gcc)

cd test
g++ -std=c++11 -Isrc -Iinclude test.cpp -o test
./test

or using CMake

mkdir build
cd build
cmake ..
make
./erkir_test

Windows

cd test
cl /I..\src /I..\include /W4 /EHsc test.cpp /link /out:test.exe
test

or using CMake

mkdir build
cd build
cmake .. -G "NMake Makefiles"
nmake
erkir_test

Performance Tests

I measured performance (on Intel Core i5 series processor) for some spherical geodesy functions (Point class). I used similar approach as Chris Veness did in his tests, i.e. called functions for 5000 random points or pairs of points. And here are my results:

Function Avg. time/calculation (nanoseconds)
Distance (haversine) 162
Initial bearing 190
Destination point 227

of course timings are machine dependent

See Also

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].