-
Graphing 1.1.0 Stable
released this
2024-03-13 10:36:23 -04:00 | 39 commits to main since this releaseGraphing 1.1.0
This is the second release of the graphing calculator. This update focuses more
on the optimization of general equations in the engine. The main improvement is
that the original computing method would do a whole lot of duplicate work if
you moved the viewport. We've already calculate the value of the equation at a
given point, we shouldn't have to do that again.So in this update, a caching system has been implemented. It is most targeted
to theEquationgraphable, but also partially applies to theSlopeField
graphable. Values generated during rendering are cached by the graphable to be
reclaimed faster in future calls for a value at a given point. The caches get
fairly big but not huge. In all my testing, the cache rarely got above 2 MB.
The total cache depends of course on the amount of equations being graphed, but
assuming it remains at a reasonable level, the memory usage will certainly stay
in the single-digit megabyte range.The cached data can be visualized in the UI by using the toolbar. Go to Misc >
View Caches to see the caches. A window will open up displaying a pie chart of
the memory usage and the ability to reset a given equation's cache. Note that
resetting a cache does not guarantee it will go entirely to zero, as some data
is required for the first-time render. But it will certainly shrink to just a
few kilobytes.It's a medium-sized tweak, but I'm proud of it. In addition, I've also added
the some more graphables, including a tangent line of a equation at a point
(use theTangentLinegraphable) and a simple bar graph (use theColumnTable
graphable). I guess I've never specified directly, but you can script this
calculator. You can write your own graphables simply by deriving from the
abstractGraphabletype and implementing the required methods. I may make a
wiki detailing how to write your own graphables in the future.The other decent change is to add the ability to draw more than just lines.
Rather than a graphable generating just a collection ofGraphLines, it now
generates a collection ofIGraphParts, whereGraphLinederives from. In
addition to a line now, aGraphUICircleexists, which draws a
constant-pixel-size circle at a position in graph space, and a
GraphRectangle, which draws a rectangle in graph space. The UI circle is used
in the tangent line graphable and the rectangle in the column table
respectively. More graph parts can be scripted as well, just by deriving from
theIGraphPartinterface.Anyway, that's the big stuff. Here's a more detailed list of every change:
- Added the ability to format a number in terms of file size (eg. "1024" → "1.00 KB")
- Added a form control that draws a pie chart given some values and colors.
- Made the base graph colors (axis colors, semi-axis colors, etc.) static constants at the top of the file.
- Enabled anti-aliasing in the graph.
- Replaced the built-in line rendering scheme with a more generalized part rendering scheme.
- Moved the code that renders lines from
GraphForm:157-167toGraphLine:23-30
- Moved the code that renders lines from
- Started using
double.IsFiniteas opposed todouble.IsNormal, because apparently zero is not normal. - The
GraphForm.Graphmethod now accepts a collection of items to graph rather than just one. - Prevented some extra casting when regenerating menu items.
- Changed the integral step from
0.1to0.01. - Added a button in the UI that opens a form to view graph caches.
- Replaced namespace with a file-scoped namespace in
SetZoomForm - Added a form to view graph caches.
- Replaced the return type of the abstract
GetItemsToRenderfrom anIEnumerable<Line2d>to anIEnumerable<GraphLine>. - Added the following abstract methods in
GraphableGraphable DeepCopy()void EraseCache()long GetCacheBytes()
- Added the
ColumnTablegraphable which represents a bar graph. - Added a
List<Float2>cache in theEquationgraphable. - Rather than calling the delegate directly, the
Equationattempts to load its cached value first. - Renamed
Line2dtoGraphLine - Added a
List<Float2>cache in theEquationgraphable. - Added a
TangentLinegraphable which represents a tangent of an equation at one point. - Added the
IGraphPartinterface. - Added a rectangle graph part (
GraphRectangle). - Added a UI circle graph part (
GraphUICircle).
Downloads