-
Notifications
You must be signed in to change notification settings - Fork 85
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
Intersection inconsistency between intersects and intersection for triangle and segment #728
Comments
Thank you @jtveiten for reporting the issue. I can reproduce it. It is a corner point intersection: viz([s1, t1], color = ["red", "teal"]) The bug is in the |
@dorn-gerhard did you write our |
Hi, No, I haven't implemented Triangle - Segment. I think another refactoring might be necessary to consider intersection of objects of different dimensionality.
Since we have two Geometries A and B in an intersection we could have combinations of these three cases above.
A Ray touching a corner of a Triangle (could be both also in the same plane) would be TouchingCrossing instead of CornerTouching Btw: segments, lines or rays that lie in the same plane as the triangle might not yield results:
|
You can use the julia> @which intersects(s1, t1)
intersects(c::Chain, g::Geometry)
@ Meshes ~/.julia/dev/Meshes/src/predicates/intersects.jl:64 In this case we have a general method for Chain and Geometry. You can also discover this using the VSCode debugger by typing
These are very welcome. We are always doing that to improve the code organization.
The Meshes.jl/src/intersections/segments.jl Line 206 in 3f1ea5e
|
I added an issue / suggestion: #734 with a better description for refactoring intersection types using inner and outer points and their dimensionality to define Overlapping, Crossing and Touching for general geometries |
I'm not sure this is the same bug, but even in the 2D case using Meshes
using CairoMakie
cg = Meshes.CartesianGrid((0.0, 0.0), (2.0, 1.0), (0.1, 0.1))
ps = Meshes.Point2[(0.0, 0.0), (1.0, 0.5), (1.0, 1.0), (2.0, 0.0)]
pol = Meshes.PolyArea(ps)
viz(pol,showfacets = true)
for i in faces(cg, 2)
cl = i ∩ pol # Same thing happens with clip(i,pol, SutherlandHodgman())
if cl != nothing
viz!(i,showfacets = true, alpha = 0.5, facetcolor = :red)
end
end
Makie.current_figure() |
@CNOT can you please open a separate issue with this MWE? It doesn't seem related. |
This bug is now fixed. The original article contains the following theorem: There is an additional condition on the first vertex Q1 of the segment: it must not be coplanar with the triangle. In this case, we need to swap the vertices Q1 and Q2 before running the algorithm. A patch release in on its way. |
Check intersection between triangle and segment, the intersection check seems to be different for intersects and intersection
julia> s1=Segment((0.5,0.5,0.), (0.5,0.5,2.0))
Segment{3,Float64}
├─ Point(0.5, 0.5, 0.0)
└─ Point(0.5, 0.5, 2.0)
julia> t1=Triangle((1.0,0.,0.),(0.,1.,0.),(0.,0.,1.))
Triangle{3,Float64}
├─ Point(1.0, 0.0, 0.0)
├─ Point(0.0, 1.0, 0.0)
└─ Point(0.0, 0.0, 1.0)
julia> intersects(s1,t1)
true
julia> intersection(s1,t1)
Intersection{Nothing}(NotIntersecting, nothing)
s1=Segment((0.5,0.5,-0.0001), (0.5,0.5,2.0))
Segment{3,Float64}
├─ Point(0.5, 0.5, -0.0001)
└─ Point(0.5, 0.5, 2.0)
julia> intersection(s1,t1)
Intersection{Point3}(Intersecting, Point(0.5, 0.5, -1.100465205072787e-17))
system info:
julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39 (2023-12-25 18:01 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 8 × Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 1 on 8 virtual cores
julia> using Pkg; Pkg.status()
Status Project.toml`
[13f3f980] CairoMakie v0.11.7
[e9467ef8] GLMakie v0.9.7
[ee78f7c6] Makie v0.20.6
[eacbb407] Meshes v0.40.4
[8913a72c] NonlinearSolve v3.5.3
[6fe1bfb0] OffsetArrays v1.13.0
[91a5bcdd] Plots v1.40.0
[1c621080] TestItems v0.1.1
The text was updated successfully, but these errors were encountered: