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 IntersectBox problem #17

Open
GoogleCodeExporter opened this issue Apr 14, 2015 · 0 comments
Open

AABB IntersectBox problem #17

GoogleCodeExporter opened this issue Apr 14, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

I tried to use the function intersectBox(AABB b) in order to calculate the 
intersection between two different boxes that I previously created.
The problem was that, to orient the boxes on the face of the other box, I was 
rotating the extent vector of the box of multiples of PI/2, in order to swap x 
and y.
But this would cause the intersectBox function not to work (I believe because 
the extent vector components would become negative). I've wrote an intersect 
function myself in Processing, and this one seems to work fine:

boolean intersectsBox2(AABB other){
    boolean intersecting = false;

    Vec3D diff = other.sub(boundingBox);

    Vec3D extent = boundingBox.getExtent();
    Vec3D otherExtent = other.getExtent();

    // I wrote the function in 2D, it should work in 3D as well
    if(abs(diff.x) <= (abs(extent.x) + abs(otherExtent.x)) && abs(diff.y) <= (abs(extent.y) + abs(otherExtent.y))){
      intersecting = true;
    }

    return intersecting;
  }

Hope this helps... Let me know if you think it can work or if there are any 
other ways to fix it.

Original issue reported on code.google.com by a.rossi....@gmail.com on 11 Jun 2013 at 10:13

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

No branches or pull requests

1 participant