nav_types/
lib.rs

1#![cfg_attr(feature = "dev", allow(unstable_features))]
2
3//! Easily work with global positions and vectors.
4//!
5//! This crate is intended to allow easy and safe interoperability between
6//! different global position and vectors in different coordinate systems.
7//! The create is built on top of [nalgebra](http://nalgebra.org/doc/nalgebra/)
8//! and strives to be compatible with types from that crate.
9//!
10//! # Example
11//! ```rust
12//! use nav_types::{ECEF, WGS84, ENU, NED};
13//!
14//! // Define positions using latitude and longitude on the WGS84 ellipsoid
15//! let oslo = WGS84::from_degrees_and_meters(59.95, 10.75, 0.0);
16//! let stockholm = WGS84::from_degrees_and_meters(59.329444, 18.068611, 0.0);
17//!
18//! println!("Great circle distance between Oslo and Stockholm: {:?}",
19//!     oslo.distance(&stockholm));
20//!
21//! // Calculate vectors between positions
22//! // This is equivalent of doint `ECEF::from(stockholm) - ECEF::from(oslo)`
23//! let vec = stockholm - oslo;
24//! println!("Vector between Oslo and Stockholm: {:?}", vec);
25//!
26//! // Easily convert between ENU and NED vectors
27//! let ned_vec = NED::new(1f32, 0.0, 1.0);
28//! let new_vec = vec + ned_vec;
29//!
30//! // Add vectors to positions
31//! let stockholm_2 = ECEF::from(oslo) + new_vec;
32//! ```
33//!
34//! # Where to begin
35//! If you are unsure where to begin I would recommend you to research which
36//! type of date you have available. Most of the time this is where you
37//! should start. If no source is available or you are free to choose I recommend
38//! that you start with `ECEF` and `ENU`. `ECEF` is efficient to calculate with
39//! and `ENU` is quite straight forward and used in many contexts.
40
41extern crate nalgebra as na;
42
43#[cfg(test)]
44#[macro_use]
45extern crate quickcheck;
46#[cfg(test)]
47extern crate assert;
48
49mod ecef;
50mod enu;
51mod ned;
52mod nvector;
53mod utils;
54mod wgs84;
55
56pub use self::ecef::ECEF;
57pub use self::enu::ENU;
58pub use self::ned::NED;
59pub use self::nvector::NVector;
60pub use self::wgs84::WGS84;
61
62// This is a private trait to access the underlying structure, this is used
63// so that this crate can access the implementation details without users
64// of this crate knowing the underlying details.
65trait Access<N> {
66    // Transfer access of underlying vector
67    fn access(self) -> N;
68}