isPointInTriangle returning true when it shouldn't
See original GitHub issueIssue details
Intersector#isPointInTriangle fails for points lying on the plane of the triangle but not within it due to a floating-point rounding error in some cases.
The last check if the function:
if (ab * bc - ac * bb < 0) return false;
is sometimes having its arithmetic being rounded to 0.0 causing the function to return true even though the answer should be false.
Reproduction steps/code
Intersector.isPointInTriangle(
new Vector3( -5120.8345f,8946.126f,-3270.5813f),
new Vector3(50.008057f, 22.20586f, 124.62208f),
new Vector3( 62.282288f, 22.205864f, 109.665924f),
new Vector3(70.92052f, 7.205861f, 115.437805f))
will return true even though the point is clearly not in the triangle.
Version of libGDX and/or relevant dependencies
Tested on version 1.10.0 however should still be failing on all versions
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Find if a point is within a triangle - Rosetta Code
Assume points are on a plane defined by (x, y) real number coordinates. Given a point P(x, y) and a triangle formed by...
Read more >Diff - platform/frameworks/base - Google Git
@param event The key event to handle. - * @return {@code true} if the event was handled. - */ - public boolean handleKeyEventIfNecessary(KeyEvent...
Read more >Unity Raycast always returning true - Stack Overflow
Could the ray be hitting my character collider? Yes, that is possible. This is actually problem that can easily be solve with Debug.Log...
Read more >doc - Apple Open Source
(_web_NSURLResponse_MIMEType): Either return the actual MIME type of the response, ... when running under Mail, the implicit <head> shouldn't be created.
Read more >Purpose of return false, new, null, true.... - Unity Forum
In general, you must return an object of the type which your function is declared as returning. i.e.. Code (csharp):. public int foo(){ ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like this new function that @tommyettinger created is working well. I’ll try to remember and create a pull request tonight
Hooray for numeric stability!