Skip to content
New issue

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

missing term in equation? #12

Closed
notwa opened this issue Dec 29, 2020 · 2 comments · Fixed by #21
Closed

missing term in equation? #12

notwa opened this issue Dec 29, 2020 · 2 comments · Fixed by #21

Comments

@notwa
Copy link

notwa commented Dec 29, 2020

I was snooping through the code and I found something peculiar.

spline/src/hyperbezier.rs

Lines 261 to 263 in e4718e9

let a = (bias - 1.0).min(MAX_A);
let norm = 1.0 / (1.0 - a) + (1.0 - a).ln() - 1.0;
(1.0 / (1.0 - a * s) + (1.0 - a * s).ln()) / norm

it may be that it doesn't matter in the context of compute_theta, but when bias ≥ 1.0002, integrate_basis has a huge y-offset for smaller values of bias. for instance, integrate_basis(1.0002, 0.0) = 49986667.306. I believe the numerator is missing a -1 term, like so:

    (1.0 / (1.0 - a * s) + (1.0 - a * s).ln() - 1.0) / norm
@raphlinus
Copy link
Contributor

Good catch! From a mathematical point of view, it doesn't matter because only the definite integral is computed (any integration constant is subtracted out). But because these values can get large, it reduces precision, so adding your term would be an improvement.

I'll happily take a PR, or fold this into another commit as I continue work.

@notwa
Copy link
Author

notwa commented Dec 29, 2020

nah, you should just commit this yourself.

raphlinus added a commit that referenced this issue Jan 28, 2021
This replaces the fixed subdivision with a dynamic approach, and also
changes the parametrization to do a better job when tension goes up.
It's a bit hacky and heuristic, rather than being based on careful
tuning of parameters to approach an optimized rendering, but it should
be a big improvement over the current situation.

Fixes #15

Also closes #12 while I'm deep in the curve math.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants