Meshes.jl icon indicating copy to clipboard operation
Meshes.jl copied to clipboard

`Box`-`Triangle` intersection in 3D

Open cserteGT3 opened this issue 11 months ago • 5 comments

I discovered the following:

t = Triangle((Point(-60.0, -35.0, 55.0), Point(-68.75, -33.43333, 54.90143), Point(-68.75, -35.0, 55.0)))
b = Box((-77.5, -35.0, 54.6073),(-68.75, -31.8914, 55.0))
intersects(b, t)

Running this code causes an infinite loop here: https://github.com/JuliaGeometry/Meshes.jl/blob/4f1a5d86e23d80465e10c45a183bbd7249e6c7fc/src/predicates/intersects.jl#L96-L104

In this particular case changing the argument order solves the issue (running intersects(t,b)), but in general it does not solve the issue. I tried normalizing my input, but it doesn't help.

s = maximum(sides(boundingbox([t, b])))
tn = Scale(1 / s)(t)
bn = Scale(1 / s)(b)
intersects(bn, tn)

I am not sure why is this the case, on other triangle-box pairs it works fine. Maybe because they have one vertice that is common?

cserteGT3 avatar Mar 22 '24 15:03 cserteGT3

@MachSilva if I remember correctly, you contributed the GJK algorithm in the 3D case, right? Appreciate if you can take a look to see if this corner case can be fixed.

juliohm avatar Mar 22 '24 18:03 juliohm

Yes. I'll take a look into it.

MachSilva avatar Mar 22 '24 18:03 MachSilva

@MachSilva appreciate if you can take a look at it. I will be working on other fronts tomorrow before the next minor release.

juliohm avatar Apr 03 '24 01:04 juliohm

Sorry for the delay. I've taken a look for some time and I didn't found the cause of the loop yet. I've been looking it in my spare time only. So, I can't tell how much time I'll take to fix it, but I'll still look for a fix.

MachSilva avatar Apr 03 '24 16:04 MachSilva

Thank you for taking a look into it @MachSilva ❤️

juliohm avatar Apr 22 '24 18:04 juliohm