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 9162845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:18:36+00:00 2026-06-17T14:18:36+00:00

I am having some trouble figuring out if 2 rectangular prisms touch or overlap.

  • 0

I am having some trouble figuring out if 2 rectangular prisms touch or overlap. I only have the highX,Y,Z and lowX,Y,Z of both rectangular prisms. Here is what I have so far:

    public boolean overlaps(AreaSelection other) {
    boolean Xs = (lowX <= other.getHighestX()) && (other.getLowestX() <= highX);
    boolean Ys = (lowY <= other.getHighestY()) && (other.getLowestY() <= highY); 
    boolean Zs = (lowZ <= other.getHighestZ()) && (other.getLowestZ() <= highZ);
    return (Xs && Ys && Zs);        
}

Does anyone know if this is correct or not? And if not, what is the solution? Thanks!

  • 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-17T14:18:37+00:00Added an answer on June 17, 2026 at 2:18 pm

    Two rectangular prisms with edges parallel to the coordinate axes overlap if and only if the respective three pairs of projected intervals on coordinate axes all overlap.

    So it makes sense to have a “utility” method which checks for overlap of intervals, which we call three times to check for overlap of the prisms. We assume this method will be called with the intervals’ endpoints properly ordered:

    public boolean overlap_1d(double aLow, double aHigh, double bLow, double bHigh)
    {
        if (aLow <= bLow) return (bLow <= aHigh);
        /* else aLow > bLow */
        return (aLow <= bHigh);
    }
    

    The original code would then become:

    public boolean overlaps(AreaSelection other)
    {
        boolean Xs = overlap_1D(lowX,highX,other.getLowestX(),other.getHighestX());
        boolean Ys = overlap_1D(lowY,highY,other.getLowestY(),other.getHighestY());
        boolean Zs = overlap_1D(lowZ,highZ,other.getLowestZ(),other.getHighestZ());
        return (Xs && Ys && Zs);        
    }
    

    Note that in this approach overlap may consist of a single point of intersection (whether in one dimension or three).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some trouble figuring out why I am only receiving one reply
I'm having some trouble figuring out to call methods that I have in other
I'm having some trouble figuring this out. I have an unordered list menu that
I'm having some trouble figuring this out. I have the following CSV string hello
I'm having some trouble figuring out how to do this. I want to have
I have been having some trouble figuring out how exactly I get a process's
I'm having some trouble figuring out the right way to do this: I have
I'm having some trouble figuring out why I can only get the children of
I have created my own blocking queue and I'm having some trouble figuring out
I'm having some trouble figuring this out. I have a script that checks a

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.