• That-One-Nerd released this 2024-03-13 10:36:23 -04:00 | 39 commits to main since this release

    Graphing 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 the Equation graphable, but also partially applies to the SlopeField
    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 the TangentLine graphable) and a simple bar graph (use the ColumnTable
    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
    abstract Graphable type 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 of GraphLines, it now
    generates a collection of IGraphParts, where GraphLine derives from. In
    addition to a line now, a GraphUICircle exists, 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
    the IGraphPart interface.

    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-167 to GraphLine:23-30
    • Started using double.IsFinite as opposed to double.IsNormal, because apparently zero is not normal.
    • The GraphForm.Graph method 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.1 to 0.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 GetItemsToRender from an IEnumerable<Line2d> to an IEnumerable<GraphLine>.
    • Added the following abstract methods in Graphable
      • Graphable DeepCopy()
      • void EraseCache()
      • long GetCacheBytes()
    • Added the ColumnTable graphable which represents a bar graph.
    • Added a List<Float2> cache in the Equation graphable.
    • Rather than calling the delegate directly, the Equation attempts to load its cached value first.
    • Renamed Line2d to GraphLine
    • Added a List<Float2> cache in the Equation graphable.
    • Added a TangentLine graphable which represents a tangent of an equation at one point.
    • Added the IGraphPart interface.
    • Added a rectangle graph part (GraphRectangle).
    • Added a UI circle graph part (GraphUICircle).
    Downloads