Show HN: KGraph, a GPU-accelerated graph plotter
kaapporaivio.fiHave you ever lost your mind at Desmos or Geogebra for occasionally being so god-damn slow and laggy? I have and, as a result, decided to make my own, GPU-accelerated (webgl2) graph plotter that renders equations, shaded plots, etc. with butter-smooth framerates.
Equations we are used to think as unplottable (with usable real-time performance), like for example `e ^ (sin(x) * x ^ 2 * cos(y)) = cos(e ^ (x * y))`, will render just as smoothly [0] as something simple, like `y = x ^ 2`.
Goals: * Rendering (almost) any equation without performance problems * Enabling acquiring new insights from being able to closely interact with complicated equations * Having an intuitive, easy-to-use and not-buggy interface
Non-goals: * Being a general-purpose CAS software
KGraph is under active development, and features such as parametric equations are coming in the near future!
Thank you for your feedback!
[0]: https://kaapporaivio.fi/graph/?d=camera%3A%28current%3A%28x%... This looks great! I use Desmos and GeoGebra a lot for teaching, and things like implicit curves are often frustratingly slow with them. Can you explain a bit how KGraph works? Do you plan to open source it? (No judgement if not.) You can get maths notation input using MathQuill: http://mathquill.com/ (that's what Desmos uses) Thanks for your feedback! Sure! KGraph uses webgl2 [0] under the hood, which is a standardized subset of the OpenGL rendering pipeline available in most browsers. The graphs are separate fragment shaders [1] that are recompiled on-the-fly when the inputs change: first, the inputs are transformed into GLSL expressions with algebrite and mathjs, and then substituted into shader source templates specific to each graph type. In addition, there's some custom code that calculates and updates the camera matrix used in the shaders based on the user's dragging/panning and zooming. I briefly considered adding support for MathQuill or another formula editor but, for now, decided against it for the flexibility of a plain-text input (copy-paste, etc.). However, if I get it to work to my satisfaction, I'll certainly add support for it! Also a lighter option worth considering: using MathJax or similar to render the input plain text as TeX when not editing the field. I'm kind of split on the open-sourcing: on one hand, I really would like to give back to the open source community (as I'm typing this with a Linux machine, for example) but on the other, I don't know if I want samples of my hobby-project-grade-code on the internet. Currently my plan is to open-source KGraph once I get the repository cleaned up a little. 0: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/T...
1: https://webglfundamentals.org/webgl/lessons/webgl-shaders-an... Copy and paste actually works fine with MathQuill. It copies as Latex code, and accepts other Latex code pasted in (within its limitations). Do you handle explicit and implicit plots differently, or treat everything as implicit? But what if the user wants to paste non-latex code? But yes, I agree that it would have benefits. Explicit functions are turned into implicit ones by rearranging (and adding a `y = ` to the beginning if necessary). This way the shader code is the same