adamconkey / computational_geometry

Playing around with implementing computational geometry algorithms from scratch in Rust.
0 stars 0 forks source link

Add visualizer for 2D polygons #1

Open adamconkey opened 1 week ago

adamconkey commented 1 week ago

Would like to add some simple support for visualizing 2D polygons. Currently I just draw things on paper and trust that I'm translating them correctly in the code (unit tests), which is error prone and unsatisfying, particularly as the polygons get more complex.

A quick search makes me think egui_plot might be a good option to start with, since it seems to support web-based plotting (important for my server setup) and already has the polygon/line/etc. primitives for visualization. That might be the easiest way to hit the ground running, create converters to generate the needed primitives for the visualization library and then generate from there. Seems that framework also has some basic support for widgets and such which may be really helpful for creating algorithm visualizations.

Ultimately just want something basic to start with, as things progress could try switching to something more impressive.

adamconkey commented 3 days ago

Still on board with egui_plot at the moment, especially seeing the demo, makes me think it could be a very nice way to host visualizations based on outputs from the test suite. I have to figure out how to get a minimal example running locally first, but my thought is I could setup tests to optionally output visualizations to some standard directory, and then the visualizer would look in there and serve anything it finds. And then in the web app you'll be able to browse the visualizations in some semi-interactive way.

adamconkey commented 9 hours ago

Basic demo of plotting a polygon working on branch feature/add_basic_plotting with egui_plot. I took their demo code and pared it down to a minimal version that support plotting polygons. Though I realize now they only support convex polygons, so I'll likely have to roll my own using more primitive visualizations, composing points and line segments to show the whole polygon boundary. Though for triangulations maybe I can still leverage the egui_plot built-ins since each triangle will be convex.

Need to take one of my actual test polygons that's non-convex and work on building a visualization for it. Then need to figure out how to get the test outputs saved and then loaded into the visualizer, and then also how to scale the GUI navigation for adding arbitrary plots to browse through, not sure if they have something like a file explorer already supported?