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

aabb capsule intersection bug #55

Closed
knowthyselfcn opened this issue May 20, 2019 · 4 comments
Closed

aabb capsule intersection bug #55

knowthyselfcn opened this issue May 20, 2019 · 4 comments

Comments

@knowthyselfcn
Copy link

knowthyselfcn commented May 20, 2019

{
    math::vec minPoint = math::vec(  438.420929 , 805.586670 , 493.709167 );
    math::vec maxPoint = math::vec( 443.420929 ,810.586670 ,498.709167 );
    math::AABB aabb(minPoint, maxPoint);

    math::vec a( 479.665222 ,-30.0000000,509.737244 );
    math::vec b( 479.665222 , 1530.00000 , 509.737244 );

    math::Capsule cylinder(a, b, 37.6882935);

    if (cylinder.Intersects(aabb))
    {
        std::cout << "MathGeoLib intersects\n";
    }
}

Error: Assumption ""insideSimplex || dist <= d[4] + 1e-4f * Max(1.f, d[4], dist)", d[4]: 0.0750471, dist: 0.213954, insideSimplex: 0, minDistIndex: 11 in \src\Algorithm\GJK.cpp:237" failed! in file \src\Algorithm\GJK.cpp, line 237!

@knowthyselfcn
Copy link
Author

knowthyselfcn commented May 20, 2019

image

juj added a commit that referenced this issue May 21, 2019
…ssertion failure, however the collision test in the test case still reports wrong result (no collision - whereas the AABB and Capsule should collide)
@juj
Copy link
Owner

juj commented May 21, 2019

Thanks for the test case! Debugged this a bit, and lifted the assertion checks to utilize double precision floating point in the above commit. That causes the assertion failure to not fire - however the collision test still reports wrong result - no collision even though the AABB and Capsule should collide (if I interpreted the numbers correctly?)

The commit above at least avoids the math assume failure. Not sure if there is a bug in the GJK algorithm implementation or if this is a limitation of single precision floating point - the numbers have relatively large range, and some of the intermediate computations exceed the scale 1e6, so the issue may be that single precision floats do not have enough resolution to detect the collision.

@knowthyselfcn
Copy link
Author

{
    gte::Vector<3, float> minPoint({ 438.420929, 805.586670, 493.709167 });
    gte::Vector<3, float>  maxPoint({ 443.420929, 810.586670, 498.709167 });
    gte::AlignedBox3<float>   aabb(minPoint, maxPoint);

    gte::Vector<3, float> a({ 479.665222, -30.0000000, 509.737244 });
    gte::Vector<3, float> b({ 479.665222, 1530.00000, 509.737244 });
    gte::Vector<3, float> dir = a - b;    gte::Normalize(dir);
    float height = gte::Length(a - b);

    gte::Line3<float> axis( a, dir);
    gte::Cylinder3<float> cylinder(axis, 37.6882935f, height);

    gte::TIQuery<float, gte::AlignedBox3<float>, gte::Cylinder3<float> > query;
    gte::TIQuery<float, gte::AlignedBox3<float>, gte::Cylinder3<float> >::Result res = query(aabb, cylinder);
    if (res.intersect)
    {
        std::cout << "gte intersects\n";
    }
    
}

The image above shows that AABB and Capsule should not collide(OSG). I also test this case with GeometricToolsEngine3p25. It reports no collision.

@juj juj closed this as completed in 0f992be May 22, 2019
@juj
Copy link
Owner

juj commented May 22, 2019

Oh, thanks! Then it looks like MathGeoLib does compute the proper result after the commit above. Updated the test and closed as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants