add homography crate, use Matrix3 to store EDH

This commit is contained in:
Marc Planard 2023-07-01 14:34:30 +02:00
parent 63c700f12d
commit 5470a9b78a
4 changed files with 19 additions and 7 deletions

View File

@ -11,8 +11,11 @@ config = "0.13.3"
ctrlc = "3.4.0" ctrlc = "3.4.0"
env_logger = "0.10.0" env_logger = "0.10.0"
helios-dac = { version = "0.1", default-features = false, features = ["native"] } helios-dac = { version = "0.1", default-features = false, features = ["native"] }
log = "0.4.18" log = "0.4.18"
redis = "0.23.0" redis = "0.23.0"
ron = "0.8.0" ron = "0.8.0"
serde = { version = "1.0.163", features = ["derive"] } serde = { version = "1.0.163", features = ["derive"] }
toml = "0.7.4" toml = "0.7.4"
homography = { git = "https://github.com/azazdeaz/homography" }
nalgebra = "0.32.2"

View File

@ -1,6 +1,7 @@
use crate::device::{Device, Status, PlaybackState}; use crate::device::{Device, Status, PlaybackState};
use crate::errors::{LJError, LJResult}; use crate::errors::LJResult;
use crate::point::Point; use crate::point::Point;
use log::debug;
pub struct DummyDevice { pub struct DummyDevice {
state: PlaybackState state: PlaybackState
@ -27,6 +28,7 @@ impl Device for DummyDevice {
line: Vec<Point>, line: Vec<Point>,
speed: u32, speed: u32,
) -> LJResult<()> { ) -> LJResult<()> {
debug!("Draw Line at speed {speed} : {:?}", line);
Ok(()) Ok(())
} }

View File

@ -113,6 +113,7 @@ impl RedisCtrl {
// Get new EDH // Get new EDH
let edh : String = self.connection.get("/EDH/0")?; let edh : String = self.connection.get("/EDH/0")?;
let edh : Vec<Vec<f32>> = from_str(&edh)?; let edh : Vec<Vec<f32>> = from_str(&edh)?;
Ok(EDH { matrix: edh }) let edh = EDH::new(edh)?;
Ok(edh)
} }
} }

View File

@ -1,13 +1,19 @@
use crate::point::Color; use crate::point::Color;
use nalgebra::base::Matrix3;
use crate::errors::LJResult;
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct EDH { pub struct EDH {
pub matrix: Vec<Vec<f32>> //Matrix3 pub matrix: Matrix3<f32>
} }
impl EDH { impl EDH {
pub fn new(vec: Vec<Vec<f32>>) -> LJResult<EDH> {
let matrix = Matrix3::new(vec[0][0], vec[0][1], vec[0][2],
vec[1][0], vec[1][1], vec[1][2],
vec[2][0], vec[2][1], vec[2][2]);
Ok(EDH { matrix })
}
} }
#[derive(Debug, Default)] #[derive(Debug, Default)]
@ -20,6 +26,6 @@ pub struct WorldState {
pub color: Color pub color: Color
} }
impl WorldState{ impl WorldState {
} }