wgxli / complex-function-plotter

WebGL Complex Function Plotter
https://samuelj.li/complex-function-plotter/
GNU General Public License v3.0
48 stars 9 forks source link

j-invariant in theta functions #17

Closed farteryhr closed 1 year ago

farteryhr commented 2 years ago
vec2 mapping(vec2 z) {
  vec2
  a=ctheta10(vec2(0,0),z),
  b=ctheta00(vec2(0,0),z),
  c=ctheta01(vec2(0,0),z),
  s=cpow(
    cpow(a,vec2(8,0))+
    cpow(b,vec2(8,0))+
    cpow(c,vec2(8,0)),
    vec2(3,0)
  ),
  denom=cpow(
    cmul(a,cmul(b,c)),
    vec2(-8,0)
  );
  return 1.0/32.0
    *cmul(s,denom);
}

source: https://en.wikipedia.org/wiki/J-invariant#Expressions_in_terms_of_theta_functions problem near the real axis. and the code editor being narrow hurts (like programming in pico-8).. enable horizontal scrolling? and it'll be nice to make more custom function samples (like ones in readme screenshots) one-click accessible in help panel, just like all functions available.

btw, beta function is usually supported, despite it could be composed out of gamma. but like factorial (btw2 it doesn't even work with (z)!), it's nicer to also have binomial binom(n,m). btw3 a b/x y short for real(z) imag(z)? though to some extent it smells wrong mathematically... but it's some usage.

wgxli commented 2 years ago

This inaccuracy is again due to GPU/real-time limitations. The j-invariant requires more computation the closer you get to the real axis. I made several tradeoffs in the implementation of the theta functions, primarily to get the elliptic functions to plot with reasonable performance.

In one of the screenshots on the Github homepage, I provide some code for the j-invariant with all parameters adjustable. You can tweak the loop upper bounds to get more accuracy at the expense of performance: image

You can resize the entire left sidebar (including the code editor) using the handle at the lower-right. Let me know if this isn't enough, and I can add horizontal scrolling too.

The (z)! not working is a bug in the parser grammar - will fix. I'll add the beta and j-invariant as standalone functions when I get a chance.

The .x and .y notation is inherited from GLSL, since I inject the custom code directly into the shader. I'd need to monkey-patch things to rename the properties to .real and .imag. Personally I think it works fine as-is.

farteryhr commented 2 years ago

You can resize the entire left sidebar (including the code editor) using the handle at the lower-right. Let me know if this isn't enough, and I can add horizontal scrolling too.

thanks for customer service :joy:, though, following the more universal UI convention, it might better be available the whole right edge...

(about misoperation, though, another problem (maybe only under MS Edge), when some text is selected, dragging for panning sometimes hit the "loading" text (while everything properly loaded, it's invisible) resulting it "dragged out" but not panning. i can't stably reproduce it, but it might be related to selection, the "..." menu after double-clicking the canvas)

The .x and .y notation is inherited from GLSL, since I inject the custom code directly into the shader. I'd need to monkey-patch things to rename the properties to .real and .imag. Personally I think it works fine as-is.

by x y i mean the syntax / predefined variable in the formula box, as short for real(z) and imag(z), for the plotter to be easily used as 2-d function plotter, like x^y for real(z)^imag(z).

or more generally, reuse the custom variable panel that enter x=imag(z) to define an intermediate variable?

wgxli commented 1 year ago

j-invariant, beta, binom have been added. Adding custom expressions as variables is on the to-do list.