diff --git a/src/algorithm/bellande_limit.rs b/src/algorithm/bellande_limit.rs
index 0e52a17..9a94908 100644
--- a/src/algorithm/bellande_limit.rs
+++ b/src/algorithm/bellande_limit.rs
@@ -13,7 +13,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::algorithm::connections::BellandeArchError;
+use crate::algorithm::connections::{
+ euclidean_distance, vector_dot_product, vector_length, vector_subtract, BellandeArchError,
+};
use bellande_limit::make_bellande_limit_request;
use futures::future::join_all;
use serde::{Deserialize, Serialize};
@@ -389,65 +391,3 @@ fn calculate_path_box_size(path: &[Vec]) -> Result
Ok(size)
}
-
-/// Subtracts one vector from another
-fn vector_subtract(a: &[f64], b: &[f64]) -> Result, BellandeArchError> {
- if a.len() != b.len() {
- return Err(BellandeArchError::DimensionMismatch(format!(
- "Cannot subtract vectors with different dimensions: {} and {}",
- a.len(),
- b.len()
- )));
- }
-
- Ok(a.iter().zip(b.iter()).map(|(x, y)| x - y).collect())
-}
-
-/// Calculates the dot product of two vectors
-fn vector_dot_product(a: &[f64], b: &[f64]) -> Result {
- if a.len() != b.len() {
- return Err(BellandeArchError::DimensionMismatch(format!(
- "Cannot calculate dot product of vectors with different dimensions: {} and {}",
- a.len(),
- b.len()
- )));
- }
-
- Ok(a.iter().zip(b.iter()).map(|(x, y)| x * y).sum())
-}
-
-/// Calculates the Euclidean length of a vector
-fn vector_length(v: &[f64]) -> Result {
- Ok(v.iter().map(|x| x * x).sum::().sqrt())
-}
-
-/// Calculates the Euclidean distance between two points
-pub fn euclidean_distance(point1: &[f64], point2: &[f64]) -> Result {
- if point1.len() != point2.len() {
- return Err(BellandeArchError::DimensionMismatch(format!(
- "Points have different dimensions: {} and {}",
- point1.len(),
- point2.len()
- )));
- }
-
- let sum_squared: f64 = point1
- .iter()
- .zip(point2.iter())
- .map(|(a, b)| (a - b).powi(2))
- .sum();
-
- Ok(sum_squared.sqrt())
-}
-
-/// Validates if a point is within the bounds of a given space
-pub fn is_point_valid(point: &[f64], min_bounds: &[f64], max_bounds: &[f64]) -> bool {
- if point.len() != min_bounds.len() || point.len() != max_bounds.len() {
- return false;
- }
-
- point
- .iter()
- .zip(min_bounds.iter().zip(max_bounds.iter()))
- .all(|(p, (min, max))| p >= min && p <= max)
-}
diff --git a/src/algorithm/bellande_particle.rs b/src/algorithm/bellande_particle.rs
index 6f7dc85..836a9f7 100644
--- a/src/algorithm/bellande_particle.rs
+++ b/src/algorithm/bellande_particle.rs
@@ -14,4 +14,4 @@
// along with this program. If not, see .
use crate::algorithm::connections::BellandeArchError;
-use bellande_particle::make_bellande_particle_request;
+// use bellande_particle::make_bellande_particle_request;
diff --git a/src/algorithm/bellande_probability.rs b/src/algorithm/bellande_probability.rs
index b80187e..1e1074c 100644
--- a/src/algorithm/bellande_probability.rs
+++ b/src/algorithm/bellande_probability.rs
@@ -14,4 +14,4 @@
// along with this program. If not, see .
use crate::algorithm::connections::BellandeArchError;
-use bellande_probability::make_bellande_probability_request;
+// use bellande_probability::make_bellande_probability_request;
diff --git a/src/algorithm/bellande_segment.rs b/src/algorithm/bellande_segment.rs
index 017ba7b..2b40b78 100644
--- a/src/algorithm/bellande_segment.rs
+++ b/src/algorithm/bellande_segment.rs
@@ -14,4 +14,4 @@
// along with this program. If not, see .
use crate::algorithm::connections::BellandeArchError;
-use bellande_segment::make_bellande_segment_request;
+// use bellande_segment::make_bellande_segment_request;
diff --git a/src/algorithm/bellande_step.rs b/src/algorithm/bellande_step.rs
index de61bd6..d36df90 100644
--- a/src/algorithm/bellande_step.rs
+++ b/src/algorithm/bellande_step.rs
@@ -13,7 +13,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
-use crate::algorithm::connections::BellandeArchError;
+use crate::algorithm::connections::{
+ euclidean_distance, is_point_valid, vector_dot_product, vector_length, vector_subtract,
+ BellandeArchError,
+};
use bellande_step::make_bellande_step_request;
use futures::future::join_all;
use serde::{Deserialize, Serialize};
@@ -404,68 +407,6 @@ impl SpatialTransformer {
}
}
-/// Subtracts one vector from another
-fn vector_subtract(a: &[f64], b: &[f64]) -> Result, BellandeArchError> {
- if a.len() != b.len() {
- return Err(BellandeArchError::DimensionMismatch(format!(
- "Cannot subtract vectors with different dimensions: {} and {}",
- a.len(),
- b.len()
- )));
- }
-
- Ok(a.iter().zip(b.iter()).map(|(x, y)| x - y).collect())
-}
-
-/// Calculates the dot product of two vectors
-fn vector_dot_product(a: &[f64], b: &[f64]) -> Result {
- if a.len() != b.len() {
- return Err(BellandeArchError::DimensionMismatch(format!(
- "Cannot calculate dot product of vectors with different dimensions: {} and {}",
- a.len(),
- b.len()
- )));
- }
-
- Ok(a.iter().zip(b.iter()).map(|(x, y)| x * y).sum())
-}
-
-/// Calculates the Euclidean length of a vector
-fn vector_length(v: &[f64]) -> Result {
- Ok(v.iter().map(|x| x * x).sum::().sqrt())
-}
-
-/// Calculates the Euclidean distance between two points
-pub fn euclidean_distance(point1: &[f64], point2: &[f64]) -> Result {
- if point1.len() != point2.len() {
- return Err(BellandeArchError::DimensionMismatch(format!(
- "Points have different dimensions: {} and {}",
- point1.len(),
- point2.len()
- )));
- }
-
- let sum_squared: f64 = point1
- .iter()
- .zip(point2.iter())
- .map(|(a, b)| (a - b).powi(2))
- .sum();
-
- Ok(sum_squared.sqrt())
-}
-
-/// Validates if a point is within the bounds of a given space
-pub fn is_point_valid(point: &[f64], min_bounds: &[f64], max_bounds: &[f64]) -> bool {
- if point.len() != min_bounds.len() || point.len() != max_bounds.len() {
- return false;
- }
-
- point
- .iter()
- .zip(min_bounds.iter().zip(max_bounds.iter()))
- .all(|(p, (min, max))| p >= min && p <= max)
-}
-
/// Converts between different coordinate representations
pub fn convert_coordinate_system(
coordinates: &[f64],
diff --git a/src/algorithm/bellande_tree.rs b/src/algorithm/bellande_tree.rs
index aef03e1..c3399a1 100644
--- a/src/algorithm/bellande_tree.rs
+++ b/src/algorithm/bellande_tree.rs
@@ -14,4 +14,4 @@
// along with this program. If not, see .
use crate::algorithm::connections::BellandeArchError;
-use bellande_tree::make_bellande_tree_request;
+// use bellande_tree::make_bellande_tree_request;
diff --git a/src/algorithm/connections.rs b/src/algorithm/connections.rs
index 1ba515d..97e7c1e 100644
--- a/src/algorithm/connections.rs
+++ b/src/algorithm/connections.rs
@@ -34,3 +34,65 @@ impl fmt::Display for BellandeArchError {
}
}
}
+
+/// Subtracts one vector from another
+pub fn vector_subtract(a: &[f64], b: &[f64]) -> Result, BellandeArchError> {
+ if a.len() != b.len() {
+ return Err(BellandeArchError::DimensionMismatch(format!(
+ "Cannot subtract vectors with different dimensions: {} and {}",
+ a.len(),
+ b.len()
+ )));
+ }
+
+ Ok(a.iter().zip(b.iter()).map(|(x, y)| x - y).collect())
+}
+
+/// Calculates the dot product of two vectors
+pub fn vector_dot_product(a: &[f64], b: &[f64]) -> Result {
+ if a.len() != b.len() {
+ return Err(BellandeArchError::DimensionMismatch(format!(
+ "Cannot calculate dot product of vectors with different dimensions: {} and {}",
+ a.len(),
+ b.len()
+ )));
+ }
+
+ Ok(a.iter().zip(b.iter()).map(|(x, y)| x * y).sum())
+}
+
+/// Calculates the Euclidean length of a vector
+pub fn vector_length(v: &[f64]) -> Result {
+ Ok(v.iter().map(|x| x * x).sum::().sqrt())
+}
+
+/// Calculates the Euclidean distance between two points
+pub fn euclidean_distance(point1: &[f64], point2: &[f64]) -> Result {
+ if point1.len() != point2.len() {
+ return Err(BellandeArchError::DimensionMismatch(format!(
+ "Points have different dimensions: {} and {}",
+ point1.len(),
+ point2.len()
+ )));
+ }
+
+ let sum_squared: f64 = point1
+ .iter()
+ .zip(point2.iter())
+ .map(|(a, b)| (a - b).powi(2))
+ .sum();
+
+ Ok(sum_squared.sqrt())
+}
+
+/// Validates if a point is within the bounds of a given space
+pub fn is_point_valid(point: &[f64], min_bounds: &[f64], max_bounds: &[f64]) -> bool {
+ if point.len() != min_bounds.len() || point.len() != max_bounds.len() {
+ return false;
+ }
+
+ point
+ .iter()
+ .zip(min_bounds.iter().zip(max_bounds.iter()))
+ .all(|(p, (min, max))| p >= min && p <= max)
+}
diff --git a/src/mesh/mesh.rs b/src/mesh/mesh.rs
index e263e37..a05cbc0 100644
--- a/src/mesh/mesh.rs
+++ b/src/mesh/mesh.rs
@@ -17,6 +17,7 @@ use crate::config::config::Config;
use crate::data::data::DataChunk;
use crate::encryption::encryption::PublicKey;
use crate::error::error::BellandeMeshError;
+use crate::mesh::architecture;
pub use crate::metrics::metrics::MetricsManager;
use crate::node::node::{Message, Node, NodeId};
use hyper::server::conn::AddrStream;