name lines
This commit is contained in:
parent
b98aa4de26
commit
a34e37e3f7
@ -481,20 +481,31 @@ impl epi::App for MathApp {
|
|||||||
function.update_bounds(minx_bounds, maxx_bounds, available_width);
|
function.update_bounds(minx_bounds, maxx_bounds, available_width);
|
||||||
|
|
||||||
let (back_values, bars, derivative) = function.run();
|
let (back_values, bars, derivative) = function.run();
|
||||||
plot_ui.line(back_values.color(Color32::RED));
|
let func_str = function.get_func_str();
|
||||||
|
plot_ui.line(back_values.color(Color32::RED).name(func_str));
|
||||||
|
|
||||||
if let Some(derivative_data) = derivative {
|
if let Some(derivative_data) = derivative {
|
||||||
plot_ui.line(derivative_data.color(Color32::GREEN));
|
plot_ui.line(
|
||||||
|
derivative_data
|
||||||
|
.color(Color32::GREEN)
|
||||||
|
.name(function.get_derivative_str()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(bars_data) = bars {
|
if let Some(bars_data) = bars {
|
||||||
let (integral_bar, integral_line, area) = bars_data;
|
let (integral_bar, integral_line, area) = bars_data;
|
||||||
match self.settings.integral_display_type {
|
match self.settings.integral_display_type {
|
||||||
IntegralDisplay::Rectangles => plot_ui
|
IntegralDisplay::Rectangles => plot_ui.bar_chart(
|
||||||
.bar_chart(integral_bar.color(Color32::BLUE).width(step)),
|
integral_bar
|
||||||
IntegralDisplay::Line => {
|
.color(Color32::BLUE)
|
||||||
plot_ui.line(integral_line.color(Color32::BLUE))
|
.width(step)
|
||||||
}
|
.name(format!("Integral of {}", func_str)),
|
||||||
|
),
|
||||||
|
IntegralDisplay::Line => plot_ui.line(
|
||||||
|
integral_line
|
||||||
|
.color(Color32::BLUE)
|
||||||
|
.name(format!("Integral of {}", func_str)),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
digits_precision(area, 8)
|
digits_precision(area, 8)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -310,6 +310,8 @@ impl FunctionEntry {
|
|||||||
self.integral_max_x = max_x;
|
self.integral_max_x = max_x;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_derivative_str(&self) -> &str { self.function.get_derivative_str() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@ -19,6 +19,8 @@ impl BackingFunction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_derivative_str(&self) -> &str { self.derivative_1.unparse() } // TODO: maybe pretty-ify the output here? idk, it's pretty ugly
|
||||||
|
|
||||||
pub fn get(&self, x: f64) -> f64 { self.function.eval(&[x]).unwrap_or(f64::NAN) }
|
pub fn get(&self, x: f64) -> f64 { self.function.eval(&[x]).unwrap_or(f64::NAN) }
|
||||||
|
|
||||||
pub fn derivative(&self, x: f64) -> f64 { self.derivative_1.eval(&[x]).unwrap_or(f64::NAN) }
|
pub fn derivative(&self, x: f64) -> f64 { self.derivative_1.eval(&[x]).unwrap_or(f64::NAN) }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user