Download presentation

Presentation is loading. Please wait.

256
**COMPUTER GRAPHICS NOVEMBER 5, 2014 CS 482 – FALL 2014 DATA STRUCTURES**

QUAD TREES OCTREES K-D TREES BINARY SPACE PARTITIONING

257
**NOVEMBER 5, 2014: DATA STRUCTURES**

QUAD TREES 2D PARTITIONING Quad trees are used to partition two-dimensional space by recursively subdividing it into quadrants until each quadrant contains all or part of a single shape or reaches some minimum size (usually a pixel). Quad trees are effectively utilized in applications such as image representation, efficient 2D collision detection, and fractal image analysis. CS 482 – FALL 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 257

258
**NOVEMBER 5, 2014: DATA STRUCTURES**

OCTREES 3D PARTITIONING Octrees extend the notion of Quad trees into three dimensions by recursively subdividing 3D space into octants until each contains all or part of a single shape or reaches some minimum size (usually a voxel). Commonly used for view 3D image representation, frustum culling, and 3D collision detection, octrees have also proven effective in reducing a scene’s color palette. CS 482 – FALL 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 258

259
**NOVEMBER 5, 2014: DATA STRUCTURES**

OCTREES COLOR QUANTIZATION To restrict an image’s color palette to a particular size, the following octree algorithm starts by creating an octree whose leaf nodes constitute a count of how many pixels in the image possess a particular color. For each color in the scene, separate the color into 8-bit RGB components. RGB=(100, 117, 214) R: G: B: Starting with the most significant bit for each primary color, use the eight 3-bit sequences to generate indices between 0 and 7 by adding R+2G+4B. 001 7 110 2 Traverse the octree structure, using the computed indices to determine which offspring to visit, adding one to the count of the color in question in the leaf node. After finishing all pixels, if the number of leaf nodes exceeds the desired palette size, start merging leaf nodes with low counts into their parent. CS 482 – FALL 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 259

260
**K-D TREES BALANCED PARTITIONING**

K-D TREES PARTITION SPACE IN A BALANCED MANNER BY ALTERNATING BETWEEN VERTICAL AND HORIZONTAL SPLITTING OF REGIONS INTO TWO PARTS, EACH CONTAINING HALF OF THE REGION’S OBJECTS. CS 482 – FALL 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 260

261
**K-D TREES NEAREST NEIGHBOR ALGORITHM**

K-D TREES MAY BE USED TO DETERMINE WHICH OF THE ORIGINAL OBJECTS IN THE SCENE ARE CLOSEST TO A PARTICULAR LOCATION. Recursively traverse the tree until you determine which sector the new location belongs in. The object in this sector is the initial candidate for being closest. Backtrack up the tree from the leaf node to the root, determining whether the subtree on the other side of each partition contains an object that’s closer to the location in question, which would make it the new candidate for closest. This algorithm may be used to speed up ray tracing (by determining that a ray doesn’t intersect particular portioned sectors). Once the backtracking reaches the root of the tree, the current candidate object is the actual closest object to the specified location. CS 482 – FALL 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 261

262
**BINARY SPACE PARTITIONING**

BSP TREES Using a binary tree structure, object space can be partitioned into numerous half-spaces, and the viewpoint’s position in these half-spaces can be used to determine the order in which they should be rendered in the Painter’s Algorithm. A B C D2 E F D1 Pick a polygon and split the space into the part in front of the polygon and the part in back of it (splitting all intersected polygons) B A,D2,E,F C,D1 front back A B C D2 E F D1 A B C D2 E F D1 A B C D2 E F D1 B F C front back A D2 D1 E Continue this process B F C,D1 front back A D2,E B F C front back A D2,E D1 The process ends when each tree node contains one object (or sub-object) CS 482 – FALL 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 262

263
**BINARY SPACE PARTITIONING**

PAINTER’S ALGORITHM IMPLEMENTATION B F C front back A D2 D1 E When determining the order in which the objects should be displayed (e.g., in a painter’s algorithm) for a particular viewpoint, merely traverse the BSP tree recursively: If the viewpoint is in front of the root, traverse Back-Root-Front; otherwise, traverse Front-Root-Back. Example 1 Example 2 A B C D2 E F D1 A B C D2 E F D1 Viewpoint Viewpoint B-subtree: in front C-subtree, B, F-subtree C-subtree: in front C, D1 F-subtree: in front A, F, D2-subtree D2-subtree: in back D2, E Complete Traversal: C, D1, B, A, F, D2, E B-subtree: in back F-subtree, B, C-subtree F-subtree: in front A, F, D2-subtree D2-subtree: in front E, D2 C-subtree: in front C, D1 Complete Traversal: A, F, E, D2, B, C, D1 CS 482 – FALL 2014 NOVEMBER 5, 2014: DATA STRUCTURES PAGE 263

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google