Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the functions for converting vectors between ECEF and NED #100

Merged
merged 2 commits into from
May 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Expose the functions for converting vectors between ECEF and NED
jbangelo committed May 26, 2024
commit e2973bc182ac2c23f080e60ea52fe7351dfa8a9c
3 changes: 3 additions & 0 deletions swiftnav-sys/build.rs
Original file line number Diff line number Diff line change
@@ -135,6 +135,9 @@ fn main() {
.allowlist_function("wgsllh2ecef")
.allowlist_function("wgsecef2llh")
.allowlist_function("wgsecef2azel")
.allowlist_function("wgsecef2ned")
.allowlist_function("wgsned2ecef")
.allowlist_function("wgsecef2azel")
.allowlist_type("ionosphere_t")
.allowlist_function("calc_ionosphere")
.allowlist_function("decode_iono_parameters")
20 changes: 20 additions & 0 deletions swiftnav/src/coords.rs
Original file line number Diff line number Diff line change
@@ -297,6 +297,16 @@ impl ECEF {
};
azel
}

/// Rotate a vector from ECEF coordinates into NED coordinates, at a given
/// reference point. This is approporiate for converting velocity vectors.
///
/// This is the inverse of [NED::ecef_vector_at].
pub fn ned_vector_at(&self, point: &ECEF) -> NED {
let mut ned = NED::default();
unsafe { swiftnav_sys::wgsecef2ned(self.as_ptr(), point.as_ptr(), ned.as_mut_ptr()) };
ned
}
}

impl Default for ECEF {
@@ -359,6 +369,16 @@ impl NED {
pub fn d(&self) -> f64 {
self.0[2]
}

/// Rotate a vector from NED coordinates into ECEF coordinates, at a given
/// reference point. This is approporiate for converting velocity vectors.
///
/// This is the inverse of [ECEF::ned_vector_at].
pub fn ecef_vector_at(&self, ref_ecef: &ECEF) -> ECEF {
let mut ecef = ECEF::default();
unsafe { swiftnav_sys::wgsned2ecef(self.as_ptr(), ref_ecef.as_ptr(), ecef.as_mut_ptr()) };
ecef
}
}

impl Default for NED {
Loading