home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / graphics / 11657 < prev    next >
Encoding:
Text File  |  1992-11-09  |  3.5 KB  |  75 lines

  1. Newsgroups: comp.graphics
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!news.ans.net!newsgate.watson.ibm.com!yktnews!admin!watson!schultz.kgn.ibm.com!schultz
  3. From: schultz@schultz.kgn.ibm.com (schultz)
  4. Subject: Re: What are Quad Trees?
  5. Sender: @watson.ibm.com
  6. Message-ID: <1992Nov09.230108.32263@watson.ibm.com>
  7. Date: Mon, 09 Nov 92 23:01:08 GMT
  8. Reply-To: schultz@vnet.ibm.com
  9. References:  <1992Nov7.053905.18272@nuscc.nus.sg>
  10. Organization: IBM AWSD Graphics Systems
  11. Lines: 62
  12.  
  13. In article <1992Nov7.053905.18272@nuscc.nus.sg>, isc10144@nusunix1.nus.sg (CHAN NICODEMUS) writes:
  14. |> I'd like to know more about Quad trees and what they are.  I have this
  15. |> as a reading assignment for my IT class.
  16. |> 
  17. |> What are they specifically and what applications are they suitable for?
  18. |> How fast are they?
  19.  
  20. I'm not an expert, but......
  21.  
  22. A quadtree is a tree that can represent the spacial organization of data
  23. by recursively subdividing a rectangle into four pieces.  So, each node
  24. in a qt may have up to four children.
  25.  
  26. Each non-leaf node in the qt subdivides its rectangle into 4 (usually equal)
  27. rectangles.  A leaf node contains data applicable to the entire region
  28. represented by its rectangle.  Therefore, you only need to subdivide until
  29. the rectangle is small enough to contain a single 'value'.
  30.  
  31. Two of the more common uses for quadtrees are:
  32.  
  33. 1) Sparse representation of a 2D image or 'bitmap'.
  34.      Say you have an array of pixels arranged in a bitmap.
  35.      The bitmap data has 'ON' pixels filling in one of the four quadrants
  36.      of the bitmap; the rest are off.  You would need 2 nodes - one
  37.      to divide the bitmap into 4 and another leaf node that is the
  38.      child of the first, containing the 'ON' value.
  39.      
  40.      If the bitmap had a single pixel on, then you would need several
  41.      non-leaf nodes to subdivide to the point where the rectangle was the
  42.      size of a pixel and then one for the pixel itself.
  43.  
  44.      A random "blob" of pixels might be encoded with a small tree of
  45.      nodes.  Some leaf nodes might cover a sizeable rectangle, others
  46.      just one pixel.
  47.  
  48. 2) Quick location of the nearest neighbor.
  49.      Because the tree essentially encodes location information, it is not
  50.      very difficult to traverse the tree in various ways to locate a point's
  51.      nearest neighbor.  This can be used for any application where it is
  52.      important to find a near neighbor quickly.
  53.      One example I saw was to "sort" vectors before sending them to a
  54.      pen plotter with the intent of reducing "pen-up" time.  All the vector
  55.      endpoints are placed in the quadtree.  The endpoint closest to the
  56.      current pen position is selected next for drawing.  After drawing, the
  57.      pen is now at the "other" endpoint's position.  The two endpoints
  58.      for the vector are removed and the next nearest enpdoint is selected.
  59.      
  60.      The search for the nearest can be tuned to find the absolute nearest
  61.      neighbor, or with less work, one that is "nearly" nearest.
  62.  
  63. How fast are they?  Tough to say.  I imagine that finding the nearest
  64. neighbor is much faster with a quadtree, compared to doing distance
  65. calculations for all the other points.  This needs to be considered in
  66. light of the time and space needed to construct the quadtree.
  67.  
  68. There are a bunch of papers covering the properties of quadtrees.
  69. Also, octrees are the logical extension of quadtrees into 3D.
  70. There is a lot of material on octrees.
  71.      
  72. -- 
  73. Karl Schultz                             schultz@vnet.ibm.com
  74. These statements or opinions are not necessarily those of IBM
  75.