start to integrate symbolic points

This commit is contained in:
Simon Gardling 2025-12-05 21:05:15 -05:00
parent b08a727fe3
commit f6a09fe449
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
2 changed files with 35 additions and 16 deletions

View File

@ -1,7 +1,8 @@
use crate::math_app::AppSettings; use crate::math_app::AppSettings;
use crate::misc::{EguiHelper, newtons_method_helper, step_helper}; use crate::misc::{EguiHelper, newtons_method_helper, step_helper};
use crate::symbolic::try_symbolic;
use egui::{Checkbox, Context}; use egui::{Checkbox, Context};
use egui_plot::{Bar, BarChart, PlotPoint, PlotUi}; use egui_plot::{Bar, BarChart, PlotPoint, PlotUi, Points};
use epaint::Color32; use epaint::Color32;
use parsing::{AutoComplete, generate_hint}; use parsing::{AutoComplete, generate_hint};
@ -409,24 +410,42 @@ impl FunctionEntry {
// Plot extrema points // Plot extrema points
if settings.do_extrema && !self.extrema_data.is_empty() { if settings.do_extrema && !self.extrema_data.is_empty() {
plot_ui.points( for point in &self.extrema_data {
self.extrema_data let name = format!(
.clone() "({}, {})",
.to_points() try_symbolic(point.x)
.color(Color32::YELLOW) .map(|s| s.to_string())
.radius(5.0), // Radius of points of Extrema .unwrap_or_else(|| format!("{:.4}", point.x)),
try_symbolic(point.y)
.map(|s| s.to_string())
.unwrap_or_else(|| format!("{:.4}", point.y))
); );
plot_ui.points(
Points::new(name, vec![[point.x, point.y]])
.color(Color32::YELLOW)
.radius(5.0),
);
}
} }
// Plot roots points // Plot roots points
if settings.do_roots && !self.root_data.is_empty() { if settings.do_roots && !self.root_data.is_empty() {
plot_ui.points( for point in &self.root_data {
self.root_data let name = format!(
.clone() "({}, {})",
.to_points() try_symbolic(point.x)
.color(Color32::LIGHT_BLUE) .map(|s| s.to_string())
.radius(5.0), // Radius of points of Roots .unwrap_or_else(|| format!("{:.4}", point.x)),
try_symbolic(point.y)
.map(|s| s.to_string())
.unwrap_or_else(|| format!("{:.4}", point.y))
); );
plot_ui.points(
Points::new(name, vec![[point.x, point.y]])
.color(Color32::LIGHT_BLUE)
.radius(5.0),
);
}
} }
if self.nth_derivative if self.nth_derivative

View File

@ -1,5 +1,5 @@
use base64::engine::general_purpose;
use base64::Engine; use base64::Engine;
use base64::engine::general_purpose;
use egui_plot::{Line, PlotPoint, PlotPoints, Points}; use egui_plot::{Line, PlotPoint, PlotPoints, Points};
use emath::Pos2; use emath::Pos2;
use itertools::Itertools; use itertools::Itertools;