|
|
@@ -1,13 +1,13 @@
|
|
|
#![allow(dead_code)]
|
|
|
use rand::Rng;
|
|
|
-
|
|
|
+mod smoothstep;
|
|
|
|
|
|
//Constants
|
|
|
const N : usize = 5;
|
|
|
|
|
|
fn main(){
|
|
|
println!("Hello, world!");
|
|
|
- println!("{:?}", create_grid(10));
|
|
|
+ //println!("{:?}", create_grid_with_vectors(10));
|
|
|
}
|
|
|
fn dotproduct(a:Vec<f64>, b:Vec<f64>)->f64{
|
|
|
let mut sum = 0.0;
|
|
|
@@ -27,7 +27,7 @@ fn crossproduct(a:Vec<f64>, b:Vec<f64>)-> Vec<f64>{
|
|
|
|
|
|
use std::fmt::Debug;
|
|
|
|
|
|
-#[derive(Debug)]
|
|
|
+#[derive(Debug, Clone)]
|
|
|
struct GridPoint {
|
|
|
coords: Vec<f64>,
|
|
|
}
|
|
|
@@ -40,7 +40,8 @@ impl GridPoint {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-fn create_grid_point() -> GridPoint {
|
|
|
+//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 {
|
|
|
@@ -48,14 +49,11 @@ fn create_grid_point() -> GridPoint {
|
|
|
}
|
|
|
point
|
|
|
}
|
|
|
+//Create a grid of points in N dimensions between -1 and 1 for the N dimensions
|
|
|
+//
|
|
|
+
|
|
|
+
|
|
|
|
|
|
-fn create_grid(n: usize) -> Vec<GridPoint> {
|
|
|
- let mut points = Vec::new();
|
|
|
- for _ in 0..n {
|
|
|
- points.push(create_grid_point());
|
|
|
- }
|
|
|
- points
|
|
|
-}
|
|
|
|
|
|
fn distance(a: &GridPoint, b: &GridPoint) -> f64 {
|
|
|
let mut sum = 0.0;
|
|
|
@@ -63,5 +61,4 @@ fn distance(a: &GridPoint, b: &GridPoint) -> f64 {
|
|
|
sum += (a.coords[i] - b.coords[i]).powi(2);
|
|
|
}
|
|
|
sum.sqrt()
|
|
|
-}
|
|
|
-
|
|
|
+}
|