C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 18th, 2012, 03:50 AM
getsmart1 getsmart1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 2 getsmart1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 6 sec
Reputation Power: 0
Geometric search/intersection problem

Hello guys.

I decided to post this in the C forum since its what I use, but its really a general problem.

I need to find if a any given point in space (2d/3d) is inside an irregular region formed by rectangles (or cubes in 3d).

I have several different boxes with its coordinates. All of the boxes overlap with at least another box, meaning its a closed region with no holes. I want to form one big region from all these boxes and then try to find if points lie inside or outside.

I have already developed an implementation that uses search trees (quadtrees) and is efficient in looking through each of the boxes to see if the points are there. Now, some of the problems I want to solve have millions of boxes and millions of points, so I'm looking for ways of say having one big region. In 2d this could be a polygon for example which is not hard to do, but not for 3d.

Basically what I would like in the end is to form a big region where I can quickly get candidate points, which I can then process in detail with my search trees algorithms.

I've been developing the search tree algorithms for the last few days so my head is pretty biased towards that at the moment and I need some external thinking.

Any ideas?
Thanks a lot in advance!

Reply With Quote
  #2  
Old September 18th, 2012, 04:19 AM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,840 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 19 h 19 m 34 sec
Reputation Power: 1774
Cross-posted here and here
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper

Reply With Quote
  #3  
Old September 18th, 2012, 04:50 AM
getsmart1 getsmart1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 2 getsmart1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 6 sec
Reputation Power: 0
Quote:
Originally Posted by salem
Cross-posted here and here


Sorry. Yes, I forgot to mention I also posted the question in the dreamincode.net and cprogramming.com forums. Didn't mean to flood the forums, I just thought I would get different answers this way. Thanks for pointing it out.

Reply With Quote
  #4  
Old September 18th, 2012, 07:27 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is online now
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,383 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 37 m 44 sec
Reputation Power: 383
Don has written about three fifths of The Art of Computer Programming by Knuth. If he's addressed geometrical algorithms this would be quite a good reference. The programs would be written in MIX or in MMIX which could be a bit challenging at first to follow---just because these are low level languages.

Robert Sedgwick's books are more accessible.

Are your boxes convex? It's easier if they are.

Maybe you could sort the nodes in each dimension (storing all n, after all, memories are large and cheap these days) and use successive binary searches. 3D FFT time goes to heck on the third dimension because the cache hit rate sinks to nil.

With an ordered convex polygon,
I expect you know that
for plane vectors
Code:
       A
C                       P
          B

Where signum returns the sign of, and cross represents an inorder cross product
P is in triangle ABC if
signum((B-C)cross(P-C))==signum((A-B)cross(P-B))==signum((C-A)cross(P-A))
otherwise you wouldn't attempt this algorithm.
Which I'm sure can be written as the determinant of some matrix.

In 3D, I'd check signs of dot products of face normals against the vector from center of face to P. Since the face could be warped, this would only work for volumes composed of planar surfaces. Triangles. So it would work for all tetrahedra (the case that interests me most often) and a constrained set of other volumes.

Check with Sedgwick.
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #5  
Old September 19th, 2012, 01:10 AM
Lux Perpetua Lux Perpetua is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2004
Location: San Francisco Bay
Posts: 1,936 Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level)Lux Perpetua User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 h 12 m 42 sec
Reputation Power: 1312
Quote:
Originally Posted by b49P23TIvg
Don has written about three fifths of The Art of Computer Programming by Knuth. If he's addressed geometrical algorithms this would be quite a good reference. The programs would be written in MIX or in MMIX which could be a bit challenging at first to follow---just because these are low level languages.

Robert Sedgwick's books are more accessible.

Are your boxes convex? It's easier if they are.
I believe the standard reference for this type of problem is "the Dutch book," i.e., Computational Geometry: Algorithms and Applications by de Berg, Cheong, van Kreveld, and Overmars. (I just searched Google to get the exact title and authors, forgetting that the actual book was on the table in front of me!)

Anyway, it doesn't seem that the OP's problem is reducible to a single convex polyhedron. However, the Dutch book does state that while the problem of efficient point location in a general subdivision in high-dimensional space is open, efficient solutions exist for rectangular subdivisions, which they don't define but I'm guessing are similar or identical to what the OP is trying to do. The references they give are:
  • "Two- and three-dimensional point location in rectangular subdivisions," by de Berg, van Kreveld and Snoeyink (J. Algorithms, 1995)
  • "Rectangular point location in d dimensions with applications," by Edelsbrunner, Haring, and Hilbert (Comput. J., 1986)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Geometric search/intersection problem

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap