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

Assumptions about intersection points #32

Open
nickasd opened this issue Nov 5, 2018 · 5 comments
Open

Assumptions about intersection points #32

nickasd opened this issue Nov 5, 2018 · 5 comments

Comments

@nickasd
Copy link

nickasd commented Nov 5, 2018

Hi, thanks for this awesome utility.
In my application, I have to find which parts of a particular shape are overlapping with another shape. For example, given an "open circle" and a rectangle, I want to find out the arcs on the circle that are obscured (i.e. red in the following image). How can I determine these arcs? Can I assume that the intersection points are given in a particular order? If I define the blue arc with a Bézier curve, will the intersection points be listed in the same order as the Bézier points? What about a closed path, like an ellipse?
ohne titel

@thelonious
Copy link
Owner

Right now, the library only returns the intersection points themselves and, unfortunately, there is no specific order to those points. There have been other requests, for example, to get the actual parametric values where an intersection occurs on a given bézier curve. That would allow you to order from the beginning of the curve to its end (or vice versa).

As far as containment, you could test if an endpoint is contained within the rectangle. As an example of this, you could use the IntersectionQuery#pointInRectangle() function.

I haven't had a need to calculate what you describe, so I'm afraid I'm not much help with this one.

@nickasd
Copy link
Author

nickasd commented Nov 19, 2018

Thank you for your response. If the library could provide the parametric values of the intersection, that would probably be a solution to my problem. Are there any plans on implementing this?

@thelonious
Copy link
Owner

I would sincerely like to add in that functionality, but due to time restrictions (which you've witnessed first hand with my delayed response), I can't say when that would happen, unfortunately.

@thelonious
Copy link
Owner

@nickasd I was just looking over open issues. I haven't implemented returning parametric values, but I did create an example that can calculate those from the intersection points. If you're interested, you can find that here. Note that this same code should work for cubic and quadratic béziers. It also works with single segments only. You'd have to expand the logic to handle multi-segment paths.

@nickasd
Copy link
Author

nickasd commented Jun 1, 2019

Thank you very much for the update! Just to let you know that your help is not in vane: as soon as I have some time next week, I will try to have a look at the code and see if I understand enough of it to add support for the parametric intersection values (and make a PR if everything goes well). Your help is really appreciated.

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

No branches or pull requests

2 participants