Giter Club home page Giter Club logo

nav-types's Introduction

nav-types

Build Status Crates.io

This crate is designed to make it easy to work with positions and vectors that have meaning as geographic entities.

Documentation

Example

Place this in your Cargo.toml

nav-types = "0.5.2"

and use it to calculate vectors and position:

extern crate nav_types;

use nav_types::WGS84;

let pos_a = WGS84::from_degrees_and_meters(36.12, -86.67, 0.0);
let pos_b = WGS84::from_degrees_and_meters(33.94, -118.40, 0.0);

println!("Distance between a and b: {:.2}m", a.distance(&b));

All position formats can work with vectors as long as the vectors are defined in some coordinate system.

use nav_types::{WGS84, ENU};

let pos_a = WGS84::from_degrees_and_meters(36.12, -86.67, 0.0);

let vec = ENU::new(0.0, 0.0, 10.0);
let pos_a_10m_up = pos_a + vec;

// Or with `NED` vector

let ned_vec = NED::new(0.0, 0.0, -10.0);
let pos_a_10m_up_2 = pos_a + ned_vec;

Note about usage

The source is based on nalgebra and some methods are only available if importing traits from nalgebra.

Performance

Currently the only way to calculate vectors between latitude and longitude positions is to convert to ECEF format and calculate the difference there. This conversion happens behind the scenes and for this reason could be a source of some surprise. It is therefor advised to try and use ECEF for as long as possible only converting to and from at the beginning and end.

On my laptop (absolute numbers will differ on different machines, but relative differences should be similar)

running 10 tests
test ecef::add_vector    ... bench:       1,321 ns/iter (+/- 21)
test ecef::difference    ... bench:       1,306 ns/iter (+/- 16)
test ecef::from_nvector  ... bench:          21 ns/iter (+/- 1)
test ecef::from_wgs84    ... bench:         492 ns/iter (+/- 23)
test nvector::add_vector ... bench:       1,486 ns/iter (+/- 61)
test nvector::difference ... bench:       1,352 ns/iter (+/- 230)
test nvector::from_ecef  ... bench:         144 ns/iter (+/- 3)
test nvector::from_wgs84 ... bench:         382 ns/iter (+/- 16)
test wgs84::add_vector   ... bench:       2,154 ns/iter (+/- 302)
test wgs84::difference   ... bench:       2,305 ns/iter (+/- 304)

nav-types's People

Contributors

lukaskalbertodt avatar meltinglava avatar nordmoen avatar ps-groscoe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.