numworks / epsilon

Modern graphing calculator operating system.
https://www.numworks.com/resources/engineering/software/
1.75k stars 463 forks source link

Navigation / Zoom in Functions without rerenders #1884

Open bluskript opened 3 years ago

bluskript commented 3 years ago

Problem you'd like to fix

Some functions can take very long to graph. This slowdown makes navigating the graph really really annoying as you have to wait for the graph to redraw every time.

Describe the solution you'd like

Cache the rendered result (offset them / shrink them), and only render new regions of the graph that are visible.

Describe alternatives you've considered

An alternative solution would be to allow navigation / zooming while its graphing, which would alleviate the issue a little. It would still be better to cache the results though.

I intend to fix this issue myself, but I would like to know if there's any additional details I should consider before proceeding.

GabrielNumworks commented 3 years ago

Thanks for the feedback @Bluskript ! We considered blitting part of the graph around to save time, and the prototype showed some great promise, but there were issues that made the solution too inconsistent:

At the end of the day, we settled on just caching the computed values of the function, which saves some time, although not as much. For now I'm sceptical there's an elegant way to reuse the rendered graph... I think your idea of allowing navigation to interrupt the drawing is more promising. The user can already interrupt the graph by pressing Back, so the framework is there.

bluskript commented 3 years ago

when the graph pans vertically, there is an horizontal stripe that must be redrawn, as it could contain points from the curve.

Which horizontal stripe are you referring to? A simple Y shift should allow you to predictably know where the function values will end up, shouldn't it?

there are some graphical elements we cannot simply move with the graph, namely the cursor, the OK button at the time, and the floating labels that appear when the axes are off screen.

I haven't used Kandinsky much, so maybe I'm lacking some context, but could it be possible to simply store the plotted coordinates of the graph, and rather than blitting them graphically, offset them at render time? This would give you the freedom to draw any other layers without worrying about skewing them in any way.

At the end of the day, we settled on just caching the computed values of the function, which saves some time, although not as much.

What exactly is the slow part about graphing? If the computed values are cached, then that seems like it should save a lot of render time... Is it simply the pixel rasterization of the points? If so, could some optimizations be made with simplifying the graph result to be as small as possible?