+use std::collections::HashMap;
+
use anyhow::{Result, bail};
use csv::ReaderBuilder;
-use nalgebra::{Point2, Rotation2, Vector2};
+use nalgebra::{DMatrix, Point2, Rotation2, Vector2};
use structs::*;
+const POINT_WEIGHT: f64 = 0.1;
+
fn main() -> Result<()> {
let mut reader = ReaderBuilder::new()
.has_headers(false)
Point2::from(distance + Vector2::from(cart_pos.coords))
}
+
+fn points_to_grid(points: &Vec<Point2<f64>>) -> Grid {
+ let mut grid = Grid::new(0.1, HashMap::new());
+
+ for point in points {
+ let coords = (
+ (point.x % grid.resolution) as i32,
+ (point.y % grid.resolution) as i32,
+ );
+ grid.strengths.insert(
+ coords,
+ grid.strengths.get(&coords).unwrap_or(&0.0) + POINT_WEIGHT,
+ );
+ }
+
+ grid
+}
+
+#[derive(Debug)]
+struct Grid {
+ pub resolution: f64,
+ pub strengths: HashMap<(i32, i32), f64>,
+}
+
+impl Grid {
+ fn new(resolution: f64, strengths: HashMap<(i32, i32), f64>) -> Self {
+ Grid {
+ resolution: resolution,
+ strengths: strengths,
+ }
+ }
+}