fix toggling extrema/roots

This commit is contained in:
Simon Gardling 2022-03-17 03:06:12 -04:00
parent a4b876111e
commit ab31d19db0
2 changed files with 21 additions and 15 deletions

View File

@ -362,6 +362,8 @@ impl FunctionEntry {
&self.function.get_derivative_str(),
(self.integral_min_x - self.integral_max_x).abs() / (self.integral_num as f64),
self.derivative,
extrema,
roots,
)
}
}

View File

@ -51,7 +51,7 @@ impl FunctionOutput {
/// disabled, it returns `f64::NAN`)
pub fn display(
&self, plot_ui: &mut PlotUi, func_str: &str, derivative_str: &str, step: f64,
derivative_enabled: bool,
derivative_enabled: bool, extrema: bool, roots: bool,
) -> f64 {
// Plot back data
plot_ui.line(
@ -72,6 +72,7 @@ impl FunctionOutput {
}
// Plot extrema points
if extrema {
if let Some(extrema_data) = self.extrema.clone() {
plot_ui.points(
Points::new(Values::from_values(extrema_data))
@ -80,8 +81,10 @@ impl FunctionOutput {
.radius(5.0),
);
}
}
// Plot roots points
if roots {
if let Some(roots_data) = self.roots.clone() {
plot_ui.points(
Points::new(Values::from_values(roots_data))
@ -90,6 +93,7 @@ impl FunctionOutput {
.radius(5.0),
);
}
}
// Plot integral data
if let Some(integral_data) = self.integral.clone() {