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

bezier-rs parametric_to_euclidean()? #2117

Open
lucasw opened this issue Nov 23, 2024 · 3 comments
Open

bezier-rs parametric_to_euclidean()? #2117

lucasw opened this issue Nov 23, 2024 · 3 comments

Comments

@lucasw
Copy link

lucasw commented Nov 23, 2024

I'd like to convert the output of project() to a euclidean distance ratio, but I don't see that method, only euclidean_to_parametric() for going the other way- or is it there and named something different?

@github-project-automation github-project-automation bot moved this to Short-Term in Task Board Nov 23, 2024
@lucasw lucasw changed the title bezier parametric_to_euclidean()? bezier-rs parametric_to_euclidean()? Nov 23, 2024
@0HyperCube
Copy link
Member

Hello @lucasw. The bézier-rs library is not really maintained since its original creators don't contribute any more.

There is currently no function for converting parametric to euclidean. You can reasonably easily do something like:

let curve = Bezier::from_cubic_coordinates(0., 2., 4., 3., 6., 5., 7., -4.);
let parametric = 0.7;
let [before, after] = curve.split(parametric).map(|split| split.length(None));
let euclidean = before / (before + after);

Note that the performance of the length function has been significantly improved in the unreleased version compared to 0.4.

@lucasw
Copy link
Author

lucasw commented Nov 23, 2024

The bézier-rs library is not really maintained since its original creators don't contribute any more.

But it's getting some maintainance here as a part of graphite- but I shouldn't expect updates to https://crates.io/crates/bezier-rs? I'm fine with this

[dependencies.bezier-rs]
git = "https://github.com/GraphiteEditor/Graphite.git"
tag = "latest-stable"

(and if you are taking PRs I'd like to make project() return a TValue, getting an f64 tripped me up for a while before I realized the Parametric-Euclidean difference, the compiler could have told me much faster)

Thanks for pointing out split (and it turns out I didn't actually need the euclidean distance ratio, just the length of the segment before the TValue).

@Keavon
Copy link
Member

Keavon commented Nov 24, 2024

Contributions are definitely welcome! I'm also working towards a new release once I have the bandwidth to square away a few outstanding issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Short-Term
Development

No branches or pull requests

3 participants