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.function.get_derivative_str(),
(self.integral_min_x - self.integral_max_x).abs() / (self.integral_num as f64), (self.integral_min_x - self.integral_max_x).abs() / (self.integral_num as f64),
self.derivative, self.derivative,
extrema,
roots,
) )
} }
} }

View File

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