]> git.taranathan.com Git - cart.git/commitdiff
mo
authorTaran Nathan <moogoesmeow123@gmail.com>
Thu, 21 May 2026 21:58:21 +0000 (14:58 -0700)
committerTaran Nathan <moogoesmeow123@gmail.com>
Thu, 21 May 2026 21:58:50 +0000 (14:58 -0700)
Cargo.lock
roomy/Cargo.toml
roomy/src/main.rs
structs/src/lib.rs

index 95c172e9b717b4f26c10dfcc1b54bd1c70d3772d..29ef92fe74a9b127340304d6e493a06337ab1e0d 100644 (file)
@@ -314,6 +314,17 @@ version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
 
+[[package]]
+name = "roomy"
+version = "0.0.0"
+dependencies = [
+ "anyhow",
+ "csv",
+ "nalgebra",
+ "serde",
+ "structs",
+]
+
 [[package]]
 name = "ryu"
 version = "1.0.23"
index ff2fd8fe0e6eed0c08966eaf3d30f8e2d40c9a01..3c12f2ef9d02d1c6ffbeaf94c41939c914847080 100644 (file)
@@ -3,4 +3,9 @@ name = "roomy"
 version = "0.0.0"
 edition = "2024"
 
-[dependencies]
\ No newline at end of file
+[dependencies]
+anyhow = "1.0.102"
+csv = "1.4.0"
+nalgebra = "0.34.2"
+serde = { version = "1.0.228", features = ["derive"] }
+structs = {path = "../structs"}
index e7a11a969c037e00a796aafeff6258501ec15e9a..60917bcd619e87390597825aa5d280b8ed78c8c8 100644 (file)
@@ -1,3 +1,33 @@
-fn main() {
-    println!("Hello, world!");
+use anyhow::{Result, bail};
+use csv::ReaderBuilder;
+use nalgebra::{Point2, Rotation2, Vector2};
+use structs::*;
+
+fn main() -> Result<()> {
+    let mut reader = ReaderBuilder::new()
+        .has_headers(false)
+        .from_path("../generator/records.csv")?;
+    let records: std::result::Result<Vec<Record>, csv::Error> =
+        reader.deserialize::<Record>().collect();
+
+    let records = records?;
+
+    let mut points: Vec<Point2<f64>> = vec![];
+
+    for record in records {
+        points.push(record_to_point(&record));
+    }
+
+    dbg!(points);
+
+    Ok(())
+}
+
+fn record_to_point(record: &Record) -> Point2<f64> {
+    let cart_pos = Point2::new(record.cart_pos.0, record.cart_pos.1);
+    let cart_rot = Rotation2::new(record.cart_rot);
+
+    let distance: Vector2<f64> = (cart_rot * Vector2::new(0.0, 1.0)) * record.distance;
+
+    Point2::from(distance + Vector2::from(cart_pos.coords))
 }
index 2885a18643b2dbd287b2bff5afca548a80e3ce71..0af67706c943c81f53652bd3441837c5c3d12154 100644 (file)
@@ -7,10 +7,10 @@ pub struct Cart {
     pub cart_rot: Rotation2<f64>,
 }
 
-#[derive(Debug, Serialize)]
+#[derive(Debug, Serialize, Deserialize)]
 pub struct Record {
     pub cart_pos: (f64, f64),
-    ///radians
+    /// radians
     pub cart_rot: f64,
     pub distance: f64,
 }