Skip to content

I can't understand this function #157

Answered by Chlumsky
shi-yan asked this question in Q&A
Discussion options

You must be logged in to vote

It may seem that way but this is floating point arithmetics we are dealing with. The important idea here is that if endpoint distance is the answer, it has to be returned exactly. The logic of combining distances of different edges relies on this property. That's why I also make sure to always compute it the same way - as (p[i]-origin).length() and not sometimes (origin-p[i]).length(). If this rule is broken, adjacent edge segments will fight due to floating-point errors and cause artifacts. The condition makes sure that the exact endpoint distance is returned instead of orthoDistance in the maximum number of cases.

I have isolated a case for you where removing the condition will cause an…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by shi-yan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants