Cube.Pdf | CubePDF Utility , CubePDF Page | Document Editor library
kandi X-RAY | Cube.Pdf Summary
kandi X-RAY | Cube.Pdf Summary
CubePDF, CubePDF Utility, CubePDF Page, and CubePDF SDK for .NET
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Cube.Pdf
Cube.Pdf Key Features
Cube.Pdf Examples and Code Snippets
Community Discussions
Trending Discussions on Cube.Pdf
QUESTION
Given is a set S
of n
axis-aligned cubes. The task is to find the volume of the union of all cubes in S
. This means that every volume-overlap of 2 or more cubes is only counted once. The set specifically contains all the coordinates of all the cubes.
I have found several papers regarding the subject, presenting algorithms to complete the task. This paper for example generalizes the problem to any dimension d
rather than the trivial d=3
, and to boxes rather than cubes. This paper as well as a few others solve the problem in time O(n^1.5)
or slightly better. Another paper which looks promising and is specific to 3d-cubes
is this one which solves the task in O(n^4/3 log n)
. But the papers seem rather complex, at least for me, and I cannot follow them clearly.
Is there any relatively simple pseudocode or procedure that I can follow to implement this idea? I am looking for a set of instructions, what exactly to do with the cubes. Any implementation will be also excellent. And O(n^2)
or even O(n^3)
are fine.
Currently, my approach was to compute the total volume, i.e the sum of all volumes of all the cubes, and then compute the overlap of every 2 cubes, and reduce it from the total volume. The problem is that every such overlap may (or may not) be of a different pair of cubes, meaning an overlap can be for example shared by 5 cubes. In this approach the overlap will be counted 10 times rather just once. So I was thinking maybe an inclusion-exclusion principle may prove itself useful, but I don't know exactly how it may be implemented specifically. Computing every overlap (naively) is already O(n^2)
, but doable. Is there any better way to compute all such overlaps?
Anyways, I don't assume this is a useful approach, to continue along these lines.
ANSWER
Answered 2021-Sep-10 at 21:41Here's some Python (sorry, didn't notice the Java tag) implementing user3386109's suggestion. This algorithm is O(n³ log n). We could get down to O(n³) by sorting the events for all cubes once and extracting the sorted sub-sequence that we need each time, but perhaps this is good enough.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Cube.Pdf
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page