We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize sample-fn to make the curve smoother
#let sample-fn3(fn, domain, samples, sample-at: ()) = { assert(samples + sample-at.len() >= 2, message: "You must at least sample 2 values") assert(type(domain) == array and domain.len() == 2, message: "Domain must be a tuple") let (lo, hi) = domain let y0 = (fn)(lo) let is-vector = type(y0) == array if not is-vector { y0 = ((lo, y0), ) } else { y0 = (y0, ) } let pts = (lo,) let currentX = lo let lastX = lo let currentY = (fn)(lo) let lastY = (fn)(lo) let i = 0 while i < 1e4 { i = i + 1 if currentX - lastX > 1e-2 or currentY - lastY > 1e-2 { pts.push(currentX) lastX = currentX lastY = currentY } currentX = currentX + 1e-4 * (hi - lo) currentY = (fn)(currentX) } pts.push(hi) return pts.map(x => { if is-vector { (fn)(x) } else { (x, (fn)(x)) } }) }
The text was updated successfully, but these errors were encountered:
Thank you!
Sorry, something went wrong.
10k iterations?
We could allow passing a custom sample-fn to plot.add & friends, or set a default one using set-style.
sample-fn
plot.add
set-style
johannes-wolf
No branches or pull requests
Optimize sample-fn to make the curve smoother
The text was updated successfully, but these errors were encountered: