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

Box-Triangle intersection in 3D #809

Open
cserteGT3 opened this issue Mar 22, 2024 · 5 comments
Open

Box-Triangle intersection in 3D #809

cserteGT3 opened this issue Mar 22, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@cserteGT3
Copy link
Contributor

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:

while true
P = minkowskipoint(g₁, g₂, d)
if (P - O) d < zero(T)
return false
end
push!(points, P)
d = gjk!(O, points)
isnothing(d) && return true

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?

@juliohm
Copy link
Member

juliohm commented Mar 22, 2024

@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.

@MachSilva
Copy link
Contributor

Yes. I'll take a look into it.

@juliohm juliohm added the bug Something isn't working label Mar 22, 2024
@juliohm juliohm assigned juliohm and MachSilva and unassigned juliohm Mar 22, 2024
@juliohm
Copy link
Member

juliohm commented Apr 3, 2024

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

@MachSilva
Copy link
Contributor

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.

@juliohm
Copy link
Member

juliohm commented Apr 22, 2024

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

@juliohm juliohm changed the title intersects runs infinitely in an edge case Box-Triangle intersection in 3D Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants