Skip to content

Commit

Permalink
Curves - Remove unused code.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cattermole committed Nov 28, 2024
1 parent 0222417 commit 2161f00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
1 change: 0 additions & 1 deletion lib/rust/mmscenegraph/src/curve/infill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

use anyhow::bail;
use anyhow::Result;
use log::debug;
use std::cmp::Ordering;
use thiserror::Error;

Expand Down
25 changes: 3 additions & 22 deletions lib/rust/mmscenegraph/src/math/curve_fit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,21 +424,18 @@ pub fn nonlinear_line_n3(
pub struct CurveFitLinearNPointsProblem {
// Curve values we are trying to fit to
reference_values: Vec<(f64, f64)>,
reference_values_first_x: usize,

// X-coordinates of control points (fixed)
control_points_x: Vec<f64>,
}

impl CurveFitLinearNPointsProblem {
fn new(control_points_x: Vec<f64>, reference_curve: &[(f64, f64)]) -> Self {
let x_first: usize = reference_curve[0].0.floor() as usize;
let reference_values: Vec<(f64, f64)> =
reference_curve.iter().copied().collect();

Self {
reference_values,
reference_values_first_x: x_first,
control_points_x,
}
}
Expand All @@ -448,25 +445,6 @@ impl CurveFitLinearNPointsProblem {
self.control_points_x.len()
}

fn reference_y_value_at_value_x(&self, value_x: f64) -> f64 {
let value_start = self.control_points_x[0].floor() as usize;
let value_end = self.control_points_x.last().unwrap().ceil() as usize;

let mut value_index = value_x.round() as usize;
if value_index < value_start {
value_index = value_start;
} else if value_index > value_end {
value_index = value_end;
}

let mut index = value_index - self.reference_values_first_x;
if index >= self.reference_values.len() {
index = self.reference_values.len() - 1;
}

self.reference_values[index].1
}

fn interpolate_y_value_at_x(
&self,
value_x: f64,
Expand Down Expand Up @@ -665,6 +643,9 @@ pub fn nonlinear_line_n_points_with_initial(
&reference_values,
);

// TODO: Solve twice - first time we just solve for offset and
// scale of the existing parameters.

// Set up solver
let epsilon = 1e-3;
let condition =
Expand Down

0 comments on commit 2161f00

Please sign in to comment.