#![allow(dead_code)] use rand::Rng; mod smoothstep; //Constants const N : usize = 5; fn main(){ println!("Hello, world!"); //println!("{:?}", create_grid_with_vectors(10)); } fn dotproduct(a:Vec, b:Vec)->f64{ let mut sum = 0.0; for i in 0..a.len(){ sum += a[i]*b[i]; } sum } fn crossproduct(a:Vec, b:Vec)-> Vec{ let mut c = vec![0.0; 3]; c[0] = a[1]*b[2] - a[2]*b[1]; c[1] = a[2]*b[0] - a[0]*b[2]; c[2] = a[0]*b[1] - a[1]*b[0]; c } use std::fmt::Debug; #[derive(Debug, Clone)] struct GridPoint { coords: Vec, } impl GridPoint { fn new(dimensions: usize) -> Self { GridPoint { coords: vec![0.0; dimensions], } } } //Create a random vector for a point of the grid fn create_grid_vector() -> GridPoint { let mut rng = rand::thread_rng(); let mut point = GridPoint::new(N); for i in 0..N { point.coords[i] = rng.gen_range(-1.0..=1.0); } point } //Create a grid of points in N dimensions between -1 and 1 for the N dimensions // fn distance(a: &GridPoint, b: &GridPoint) -> f64 { let mut sum = 0.0; for i in 0..N { sum += (a.coords[i] - b.coords[i]).powi(2); } sum.sqrt() }