Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8935433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:58:46+00:00 2026-06-15T09:58:46+00:00

There are answers for 2D/3D bounding box collision detection, however my problem is how

  • 0

There are answers for 2D/3D bounding box collision detection, however my problem is how to develop the situation to multi-dimension (4D or more) ?

Here is the code on 3D case.

template<typename T, typename _Prd>
bool BoundingBox3<T,_Prd>::Collision( const BoundingBox3<T,_Prd>& cube ) const
{

    Point3<T,_Prd> min_1 = center - Point3<T,_Prd>(length,depth,height)/2.0;
    Point3<T,_Prd> max_1 = center + Point3<T,_Prd>(length,depth,height)/2.0;

    Point3<T,_Prd> min_2 = cube.Center() - Point3<T,_Prd>(cube.Length(),cube.Depth(),cube.Height())/2.0;
    Point3<T,_Prd> max_2 = cube.Center() + Point3<T,_Prd>(cube.Length(),cube.Depth(),cube.Height())/2.0;

    if(Volume()<cube.Volume())
    {
        Vector3D::Swap(min_1,min_2);
        Vector3D::Swap(max_1,max_2);
    }

    if(min_1[0]<=min_2[0] && min_1[1]<=min_2[1] && min_1[2]<=min_2[2]
    && max_1[0]>=min_2[0] && max_1[1]>=min_2[1] && max_1[2]>=min_2[2])
        return true;

    if(min_1[0]<=max_2[0] && min_1[1]<=max_2[1] && min_1[2]<=max_2[2]
    && max_1[0]>=max_2[0] && max_1[1]>=max_2[1] && max_1[2]>=max_2[2])
        return true;

    return false;
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:58:47+00:00Added an answer on June 15, 2026 at 9:58 am

    One box collides with another if there is an intersecting range in all dimensions.

    The intersection of range [a,b] with range [c,d] is [max(a,c),min(b,d)].

    In the case of the ranges not intersecting, the result will be an invalid range, with the start of the range greater than the end of the range.

    So the collision can be done like this:

    bool collides(const Box &box1,const Box &box2)
    {
      assert(box1.numberOfDimensions()==box2.numberOfDimensions());
      for (size_t i=0; i!=box1.numberOfDimensions(); ++i) {
        float a = max(box1.minForDimension(i),box2.minForDimension(i));
        float b = min(box1.maxForDimension(i),box2.maxForDimension(i));
        if (a>b) return false;
      }
      return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are two similar questions asked here and here but no adequate answers are
Hy. I know there are answers similar, but i can't get it going. Here
I'm using Monotouch to develop an iPhone application. I'm aware there are answers out
This is my example code: http://jsfiddle.net/pT6dB/ I have a bit of a problem. There
I have modified the code in this question ,according to the answers there, in
This question was posted on some site. I didnt find right answers there, so
There are various answers on Stack Overflow which explain the conditions under which tail
There are several useful answers on SO regarding prevention of brute forcing a password
There have been questions with answers on how to write rubygems, but what should
There are nice SO question and answers about this issue, but these options didn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.