Skip to content

Commit

Permalink
Replace Vector{2,3} with nalgebra::Vector{2,3} (#70)
Browse files Browse the repository at this point in the history
Co-authored-by: Aemulation <[email protected]>
  • Loading branch information
juliablbr and Aemulation authored Oct 10, 2024
1 parent d654b62 commit a522a9d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 654 deletions.
1 change: 1 addition & 0 deletions nidhogg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tracing = "0.1.37"
nidhogg_derive = { workspace = true }
coppeliasim_zmq_remote_api = { git = "https://github.com/samuel-cavalcanti/rust_zmqRemoteApi", optional = true }
num = "0.4.1"
nalgebra = { version = "0.32.6", features = ["serde-serialize"] }
bevy_ecs = { version = "0.14.2", optional = true }

[dev-dependencies]
Expand Down
15 changes: 5 additions & 10 deletions nidhogg/src/backend/lola.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
use crate::{
types::{
Battery, ForceSensitiveResistorFoot, ForceSensitiveResistors, JointArray, LeftEar, LeftEye,
Rgb, RgbF32, RightEar, RightEye, Skull, SonarEnabled, SonarValues, Touch, Vector2, Vector3,
Rgb, RgbF32, RightEar, RightEye, Skull, SonarEnabled, SonarValues, Touch,
},
DisconnectExt, Error, HardwareInfo, NaoBackend, NaoControlMessage, NaoState, Result,
};

use nalgebra::{Vector2, Vector3};

use rmp_serde::{encode, from_slice};
use serde::{Deserialize, Serialize};
use std::{
Expand Down Expand Up @@ -487,20 +489,13 @@ impl FromLoLA<[f32; 14]> for Touch {

impl FromLoLA<[f32; 2]> for Vector2<f32> {
fn from_lola(value: [f32; 2]) -> Self {
Vector2 {
x: value[0],
y: value[1],
}
Vector2::from(value)
}
}

impl FromLoLA<[f32; 3]> for Vector3<f32> {
fn from_lola(value: [f32; 3]) -> Self {
Vector3 {
x: value[0],
y: value[1],
z: value[2],
}
Vector3::from(value)
}
}

Expand Down
3 changes: 2 additions & 1 deletion nidhogg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ mod error;
pub mod types;

pub use error::{Error, Result};
use nalgebra::{Vector2, Vector3};
use nidhogg_derive::Builder;
use types::{
color::RgbF32, Battery, FillExt, ForceSensitiveResistors, JointArray, LeftEar, LeftEye,
RightEar, RightEye, Skull, SonarEnabled, SonarValues, Touch, Vector2, Vector3,
RightEar, RightEye, Skull, SonarEnabled, SonarValues, Touch,
};

#[cfg(feature = "serde")]
Expand Down
2 changes: 0 additions & 2 deletions nidhogg/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ use bevy_ecs::prelude::Resource;

pub mod color;
mod joint_array;
mod vector;

pub use color::{Rgb, RgbF32, RgbU8};
pub use joint_array::JointArray;
pub use vector::{Vector2, Vector3};

/// Trait that introduces the [`fill`](`FillExt::fill`) method for a type, which allows filling in all fields with the same value.
pub trait FillExt<T> {
Expand Down
Loading

0 comments on commit a522a9d

Please sign in to comment.