reliable method for getting all intersection points #5
Replies: 6 comments 2 replies
-
|
Thanks for opening this issue -- it is hard to define a completely general approach. It is always possible to find edge cases that fail in one way or another -- part of my reason for giving two different approaches was that one might work better in some situations than others, and you might like to work out how to adapt them to what you are actually trying to achieve. Let me look at your examples and see if I can find something more robust. Do you have a particular use case for finding all intersections? |
Beta Was this translation helpful? Give feedback.
-
|
As it says in the discussion in §9.4.2, the first technique only works well if the "unit subpaths" are short -- it is only ever going to find one intersection for each unit subpath. Since you have rather long subpaths in your path So you should try the second approach -- however there is a small bug in it. Try changing |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the quick response! My use case is actually trying to find the centroid of blob-like objects. For example: To find the centroid, I am approximating each blob as a series of horizontal rectangles. It is the same idea as using a rectangular approximation in a Riemann Sum. So my goal is to use the intersection points to define the ends of rectangles. And thanks for the suggestions. I tried using both approaches, but unfortunately they both seem to miss some intersection points. I also just tried changing |
Beta Was this translation helpful? Give feedback.
-
|
I've moved this to a discussion... Admittedly this ignores any Bezier curves between the points, but it might be a good enough approximation. |
Beta Was this translation helpful? Give feedback.
-
|
I recently realized that, for my needs, the best way to determine the centroid of a closed path is to approximate the path as a polygon with many vertices. Then I can use the polygon centroid formula. I have also written my own function to get all intersection points, which I will post here soon. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
First of all, thank you so much for this document. This is the best Metapost reference I've found, and I've been using it regularly!
I'm not sure if this is the right place to ask this question, but I have been having some trouble determining a reliable method to find all of the intersection points between two paths. I have implemented both methods in Section 9.4.2, but they seem to fail sometimes. Below I have code with a simple example demonstrating what I'm talking about:
Beta Was this translation helpful? Give feedback.
All reactions