fix toggling extrema/roots
This commit is contained in:
parent
a4b876111e
commit
ab31d19db0
@ -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,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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,23 +72,27 @@ impl FunctionOutput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Plot extrema points
|
// Plot extrema points
|
||||||
if let Some(extrema_data) = self.extrema.clone() {
|
if extrema {
|
||||||
plot_ui.points(
|
if let Some(extrema_data) = self.extrema.clone() {
|
||||||
Points::new(Values::from_values(extrema_data))
|
plot_ui.points(
|
||||||
.color(Color32::YELLOW)
|
Points::new(Values::from_values(extrema_data))
|
||||||
.name("Extrema")
|
.color(Color32::YELLOW)
|
||||||
.radius(5.0),
|
.name("Extrema")
|
||||||
);
|
.radius(5.0),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plot roots points
|
// Plot roots points
|
||||||
if let Some(roots_data) = self.roots.clone() {
|
if roots {
|
||||||
plot_ui.points(
|
if let Some(roots_data) = self.roots.clone() {
|
||||||
Points::new(Values::from_values(roots_data))
|
plot_ui.points(
|
||||||
.color(Color32::LIGHT_BLUE)
|
Points::new(Values::from_values(roots_data))
|
||||||
.name("Root")
|
.color(Color32::LIGHT_BLUE)
|
||||||
.radius(5.0),
|
.name("Root")
|
||||||
);
|
.radius(5.0),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plot integral data
|
// Plot integral data
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user