-
Notifications
You must be signed in to change notification settings - Fork 87
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
SutherlandHodgman not handling overlapping line intersections #950
Comments
Hi @jnemanja can you please share a MWE? Thanks for reporting the issue.
Em sáb., 20 de jul. de 2024, 13:23, jnemanja ***@***.***>
escreveu:
… In the clip function of the sutherlandhodgman.jl file, an intersection
between lines is being pushed to a vector of points. This is fine as long
as the intersection between lines is crossing and a point is returned.
However, the intersection can be overlapping when a line is returned,
resulting in an exception. Admittedly, this only happens after I override Meshes.atol(::Type{Float64})
= 1e-13 (which I need to avoid a different intersection problem). Still,
it looks like this needs updating. I have a fix which in case of an
overlapping intersection, pushes only the first point of the line. I am no
quite sure if that is sufficient, I do not know if the returned line is
always conveniently oriented to be able to always select the first point.
—
Reply to this email directly, view it on GitHub
<#950>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZQW3KBYBJ4GJKETBIYSR3ZNKFJLAVCNFSM6AAAAABLGBZHUOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZDAOJWGM3TAMA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Here it is. Reproducible without overriding the
|
I forgot to mention another part of the problem. It might even be an issue on its own, but probably it needs fixing for this issue to be properly fixed. When two overlapping lines are intersected, it just returns the first line instead of returning the line with two innermost points. This:
returns |
@jnemanja regarding your example with julia> s1 = Segment((0, 0), (2, 0))
Segment
├─ Point(x: 0.0 m, y: 0.0 m)
└─ Point(x: 2.0 m, y: 0.0 m)
julia> s2 = Segment((1, 0), (3, 0))
Segment
├─ Point(x: 1.0 m, y: 0.0 m)
└─ Point(x: 3.0 m, y: 0.0 m)
julia> s1 ∩ s2
Segment
├─ Point(x: 1.0 m, y: 0.0 m)
└─ Point(x: 2.0 m, y: 0.0 m) If you are coming from the GIS world, you will have to unlearn this incorrect naming. I will try to take a look into your original MWE above soon. |
@jnemanja we can reduce your MWE to the following intersection between julia> l1
Line
├─ a: Point(x: 0.0 m, y: 1.0 m)
└─ b: Point(x: 1.0 m, y: 1.000000000000001 m)
julia> l2
Line
├─ a: Point(x: 1.0 m, y: 1.0 m)
└─ b: Point(x: 0.0 m, y: 1.000000000000001 m)
julia>
julia> l1 ∩ l2
Line
├─ a: Point(x: 0.0 m, y: 1.0 m)
└─ b: Point(x: 1.0 m, y: 1.000000000000001 m) As you can see, these two lines are equal up to machine tolerance (i.e., Meshes.jl/src/intersections/lines.jl Lines 5 to 23 in 60996c4
As you can see, the algorithm is very simple to read and understand. What do you think we should do in this case? |
Ah right, a silly misunderstanding on my part there for line and segment distinction. I'm not even from the GIS world, so it's a learning and not unlearning opportunity. However, does this still expose a problem in the SutherlandHodgman method? The method should use segments instead of lines, or it could produce malformed intersections. |
@jnemanja I commented above with more information. The Suthreland-Hodgman algorithm uses |
Here are a few suggestions:
Please let me know if you need further help. I will mark the issue as invalid, given that it is not an issue of the clipping implementation. Our Zulip channel is a nice place to chat too. |
In the
clip
function of the sutherlandhodgman.jl file, an intersection between lines is being pushed to a vector of points. This is fine as long as the intersection between lines is crossing and a point is returned. However, the intersection can be overlapping when a line is returned, resulting in an exception. Admittedly, this only happens after I overrideMeshes.atol(::Type{Float64}) = 1e-13
(which I need to avoid a different intersection problem). Still, it looks like this needs updating. I have a fix which in case of an overlapping intersection, pushes only the first point of the line. I am no quite sure if that is sufficient, I do not know if the returned line is always conveniently oriented to be able to always select the first point.The text was updated successfully, but these errors were encountered: