Skip to content

Commit

Permalink
cosmetic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mark2b committed Dec 5, 2023
1 parent a9302e9 commit 0a48076
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ path = "src/lib.rs"

[dependencies]
libm = "0.2.8"
nalgebra = { version = "0.31.4", default-features = false, features = ["libm-force"] }
nalgebra = { version = "0.32.3", default-features = false, features = ["libm-force"] }

[dev-dependencies]
csv = "1.3.0"
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@

It is a porting of well known Fusion library
https://github.com/xioTechnologies/Fusion



The project contains [Fusion](https://github.com/xioTechnologies/Fusion) library as submodule.
It is used for tests only, in order to compare results of C implementation with Rust one.
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ mod fusion_ahrs_impl;
mod fusion_gyr_offset_impl;
mod nalgebra;

use libm::asinf;

pub enum FusionConvention {
/* North-West-Up */
NWU,
Expand Down Expand Up @@ -113,8 +111,7 @@ pub union FusionQuaternion {

#[derive(Copy, Clone)]
#[allow(dead_code)]
pub union FusionEuler {
data: [f32; 3],
pub struct FusionEuler {
pub angle: Angle,
}

Expand Down Expand Up @@ -143,6 +140,7 @@ fn fusion_radians_to_degrees(radians: f32) -> f32 {
}

fn asin_safe(value: f32) -> f32 {
use libm::{asinf};
if value <= -1.0f32 {
return core::f32::consts::PI / -2.0f32;
}
Expand All @@ -168,6 +166,9 @@ fn fusion_fast_inverse_sqrt(x: f32) -> f32 {

#[test]
fn fusion_fast_inverse_sqrt_test() {
use libm::{fabsf};
let result = fusion_fast_inverse_sqrt(9.0f32);
assert_eq!(1f32 / result, 3f32);
let actual = 1f32 / result;
let expected = 3f32;
assert!(fabsf(actual - expected) < 0.01f32);
}

0 comments on commit 0a48076

Please sign in to comment.