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

  • SEARCH
  • Home
  • 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 3214040
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:00:50+00:00 2026-05-17T15:00:50+00:00

In my program I have some cubes (simple, xyz location, xyz size). I want

  • 0

In my program I have some cubes (simple, xyz location, xyz size). I want bo be able to take one of these cubes and ‘Subtract’ another cube from it.

So my question, what is a good generic data structure to represent the resulting 3d object, and what kind of algorithm is used to subtract a 3d solid from another?

  • 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-05-17T15:00:51+00:00Added an answer on May 17, 2026 at 3:00 pm

    This is a pretty general question and depends on what you want to know about the solid and how fast you want to know it. Assuming that you only want membership tests, this might work (psuedocode):

    class Solid {
        Solid solids = [] // each Solid has a list of solids that  
                          // have been subtracted from it.                      
    
        abstract method containedInSelf(point) {
            // this will obviously vary from one type of solid to another
        } 
    
        method contains(point) {
            if !containedInSelf(point) return False;
            else {
                for solid in solids {  // loop over all contained solids
                    if solid.contains(point) return False; 
                    // point is contained in a solid that has been subtracted from it
                }
                // Now we know that point is contained but not contained in anything
                // that's been subtracted
                return True;
            }
        }
    
        method subtract(solid) {
            solids.append(solid)
        } 
    
    }
    

    This has the advantage of allowing composite subtractions. For example, you can subtract solid A from solid B and then solid B from solid C and it will work as expected. For example with three spheres centered at the origin and radius(A) < radius(B) < radius(C), you’ll get points that are contained in A or contained in C but not B.

    You can also, for example, subtract a two dodecahedrons from a sphere and then subtract that to a cube. Which is of course the same as subtracting the sphere from a cube and adding two dodecahedrons back in.

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

Sidebar

Related Questions

I have some testcases for a program, so i want to start all of
I have a cpp program with some dependencies dll (black box for me). One
In my C# WinForms program I have some forms and I show one of
I have a program where there is a master/slave setup, and I have some
I have a program running under WPF and MVVM. I have some daily worked
I have some rather odd behavior in my D program that I've narrowed down
I am making a program like yelp. Some people have some accounts. So I
So I'm working on rewriting a program for a professor, and I have some
I have written some sample program and DLL to learn the concept of DLL
I have discovered some issues in my program. I was using log4j for logging,

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.