Data Structures for Computer Graphics Point Based Representations and Data Structures Lectured by Vlastimil Havran.

Slides:



Advertisements
Similar presentations
Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
Advertisements

Nearest Neighbor Search

Spatial Data Structures Hanan Samet Computer Science Department
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
Binary Trees CSC 220. Your Observations (so far data structures) Array –Unordered Add, delete, search –Ordered Linked List –??
Multidimensional Indexing
Searching on Multi-Dimensional Data
B+-Trees (PART 1) What is a B+ tree? Why B+ trees? Searching a B+ tree
Multidimensional Data. Many applications of databases are "geographic" = 2­dimensional data. Others involve large numbers of dimensions. Example: data.
Spatial Indexing I Point Access Methods. PAMs Point Access Methods Multidimensional Hashing: Grid File Exponential growth of the directory Hierarchical.
2-dimensional indexing structure
Multiple-key indexes Index on one attribute provides pointer to an index on the other. If V is a value of the first attribute, then the index we reach.
I/O-Algorithms Lars Arge University of Aarhus March 1, 2005.
I/O-Algorithms Lars Arge Spring 2009 March 3, 2009.
CS 206 Introduction to Computer Science II 12 / 03 / 2008 Instructor: Michael Eckmann.
Lars Arge1, Mark de Berg2, Herman Haverkort3 and Ke Yi1
Spatial Indexing I Point Access Methods. Spatial Indexing Point Access Methods (PAMs) vs Spatial Access Methods (SAMs) PAM: index only point data Hierarchical.
Spatial Indexing I Point Access Methods.
Quick Review of material covered Apr 8 B+-Tree Overview and some definitions –balanced tree –multi-level –reorganizes itself on insertion and deletion.
1 Geometric index structures April 15, 2004 Based on GUW Chapter , [Arge01] Sections 1, 2.1 (persistent B- trees), 3-4 (static versions.
Bounding Volume Hierarchies and Spatial Partitioning Kenneth E. Hoff III COMP-236 lecture Spring 2000.
General Trees and Variants CPSC 335. General Trees and transformation to binary trees B-tree variants: B*, B+, prefix B+ 2-4, Horizontal-vertical, Red-black.
R-Trees 2-dimensional indexing structure. R-trees 2-dimensional version of the B-tree: B-tree of maximum degree 8; degree between 3 and 8 Internal nodes.
O RTHOGONAL R ANGE S EARCHING الهه اسلامی فروردین 92, 1.
Spatial Indexing I Point Access Methods. Spatial Indexing Point Access Methods (PAMs) vs Spatial Access Methods (SAMs) PAM: index only point data Hierarchical.
Spatial Indexing I Point Access Methods. Spatial Indexing Point Access Methods (PAMs) vs Spatial Access Methods (SAMs) PAM: index only point data Hierarchical.
Binary Trees Chapter 6.
Indexing structures for files D ƯƠ NG ANH KHOA-QLU13082.
 This lecture introduces multi-dimensional queries in databases, as well as addresses how we can query and represent multi- dimensional data.
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
B-Tree. B-Trees a specialized multi-way tree designed especially for use on disk In a B-tree each node may contain a large number of keys. The number.
ICS 220 – Data Structures and Algorithms Week 7 Dr. Ken Cosh.
B+ Trees COMP
Trees for spatial data representation and searching
1 B Trees - Motivation Recall our discussion on AVL-trees –The maximum height of an AVL-tree with n-nodes is log 2 (n) since the branching factor (degree,
IP Address Lookup Masoud Sabaei Assistant professor
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
The BSP-tree from Prof. Seth MIT.. Motivation for BSP Trees: The Visibility Problem We have a set of objects (either 2d or 3d) in space. We have.
1 B-Trees & (a,b)-Trees CS 6310: Advanced Data Structures Western Michigan University Presented by: Lawrence Kalisz.
Chapter 6 Binary Trees. 6.1 Trees, Binary Trees, and Binary Search Trees Linked lists usually are more flexible than arrays, but it is difficult to use.
© 2006 Pearson Addison-Wesley. All rights reserved13 B-1 Chapter 13 (continued) Advanced Implementation of Tables.
Multidimensional Indexes Applications: geographical databases, data cubes. Types of queries: –partial match (give only a subset of the dimensions) –range.
Mehdi Mohammadi March Western Michigan University Department of Computer Science CS Advanced Data Structure.
Multi-dimensional Search Trees
COSC 2007 Data Structures II Chapter 15 External Methods.
2IL50 Data Structures Fall 2015 Lecture 9: Range Searching.
Lecture 2: External Memory Indexing Structures CS6931 Database Seminar.
Computational Geometry Piyush Kumar (Lecture 5: Range Searching) Welcome to CIS5930.
Lecture 11COMPSCI.220.FS.T Balancing an AVLTree Two mirror-symmetric pairs of cases to rebalance the tree if after the insertion of a new key to.
Multi-dimensional Search Trees CS302 Data Structures Modified from Dr George Bebis.
Spatial Indexing Techniques Introduction to Spatial Computing CSE 5ISC Some slides adapted from Spatial Databases: A Tour by Shashi Shekhar Prentice Hall.
BINARY TREES Objectives Define trees as data structures Define the terms associated with trees Discuss tree traversal algorithms Discuss a binary.
Ray Tracing Optimizations
Multidimensional Access Structures COMP3017 Advanced Databases Dr Nicholas Gibbins –
Hierarchical Data Structure in Game Programming Yanci Zhang Game Programming Practice.
Indexing Structures for Files
School of Computing Clemson University Fall, 2012

Bounding Volume Hierarchies and Spatial Partitioning
Multiway Search Trees Data may not fit into main memory
Multidimensional Access Structures
CMPS 3130/6130 Computational Geometry Spring 2017
Spatial data structures -kdtrees
Bounding Volume Hierarchies and Spatial Partitioning
Spatial Indexing I Point Access Methods.
KD Tree A binary search tree where every node is a
Orthogonal Range Searching and Kd-Trees
Database Design and Programming
Presentation transcript:

Data Structures for Computer Graphics Point Based Representations and Data Structures Lectured by Vlastimil Havran

Point Based Data Data represented by points in multidimensional space (at least 2D) Many problems can be converted to point based representation, possibly in high dimensional space Data structures for points are usually spatial subdivisions: Non-overlapping spatial cells Each data point is only once in the data structures

Data Structures Overview Uniform grid Point quadtree Pseudo-quadtree TRIE based data structures MX-tree PR-quadtree Point Kd-tree Adaptive point Kd-tree BSP tree D-tree

Uniform Grid Representations (regular data structures)

Uniform Grid Representations Cell is directly addressed. In each cell index to the list of points Each point – two coordinates in 2D How to solve data collisions? Note A: it can also be used for 3D/4D, but memory increase makes it difficult to use Note B: efficient for relatively uniform distribution of points, in particular in 2D

Point Quadtree in 2D Partitioning planes aligned with data points Leaves may also contain data points

Point Quadtree Insertion Insertion order: 1) Chicago 2) Mobile 3) Buffalo 4) Toronto 5) Omaha 6) Denver 7) Atlanta

Point Quadtree Deletion Reconstructing the whole subtree rooted at node that contains the deleted point Candidate selection for new root in the area based on L1 (Manhattan) metric

Point Quadtree Deletion (point A) After Deletion Before Deletion

Point Quadtree Operations Overview Insertion – subdividing the cell containing more than one point Deletion of point A Find a new candidate for splitting Identify, which subtrees rooted in A are affected by deleting A Identify all the points in the changed subtrees Rebuild the tree

Pseudo-Quadtree Partitioning planes are not aligned with the data Data are only in leaves Insertion and in particular deletion is faster Higher space requirements.

TRIE based Quadtrees TRIE No data (points, positions) in interior nodes Discretization in shape of the tree Partitioning planes located exactly in the “middle” (spatial median subdivision) Either the data are also aligned with the discretization (MX-quadtree) or are specified exactly in leaves (PR-quadtree) Due to the discretization Space complexity is lower Dealing with non-uniform distribution is worse than for pseudo-quadtree

MX-trees versus PR-quadtrees

Octrees Octree has the same principles as quadtree but the different dimension. Quadtree organizes 2D space (=plane, axis x and y), each interior node has 4 children Octree organizes 3D space (axis x, y, and z), each interior node has 8 children

Kd-trees Introduction (year 1980) “K” in Kd-trees originally stands for the dimensionality of the tree The arity (also called the branching factor = number of child nodes) is always two irrespective of dimensionality of the data points Kd-trees correspond the most closely to 1D binary trees, but the interior nodes are interpreted differently (in multidimensional space) Kd-trees are very efficient and for many algorithms you can stay with kd-trees only

Point Kd-trees Organization of points Partitioning planes are aligned with the data – the data are also in the interior nodes

Incrementally Building Up Kd-tree Assumption: taking the points in random order Time complexity is then O(N log N).

Insertion and Deletion in Point Kd-trees ( Analogy to Point Quadtrees ) Deletion More difficult than insertion Requires location an interior node N and reconstruction of the whole subtree rooted at N Expected deletion cost is O(log N), as most of the data are near leaves Insertion Simple Locate a leaf and insert new partitioning plane Assuming random order of points, cost is O(log N)

Example Application: Range Search A range is given by an rectangle (in 2D) / box in (3D) Find all the points in the query rectangle Assumption: kd-tree is built Practical use: location of the cities around a visitor Analogy in databases: find out all the employees with age from 30 to 50 and salary between 2,000 to 3,000 USD

Range Search with Point kd-trees Given a partitioning plane, there are three cases for traversal: visit only left child visit both children visit only right child

Adaptive Point Kd-trees It also organizes point data The data are stored only in leaves The deletion is simpler The data storage is higher if partitioning is carried out until each leaf contains a single point Kd-trees enable to store more than one point in a leaf, which can be efficient for some queries (range search)

Adaptive Kd-tree Example

Non-adaptive versus Adaptive Point Kd-tree

Choosing Partitioning Plane Geometrically in the middle – the children cells are of the same size By data median – half of the points on the left and half of the points on the right (if the number of points is even) By other means: by assumed query distribution (“the minimum-ambiguity kd-tree”), using cost function

Choosing Partitioning Axis We have to decide in which axis we partition a set of the data circumvented by a box in the current node Methods: Round robin: x,y,z,x,y,…. Maximum extent of the box – select an axis in which box has maximum size Combination: with 30% in round robin fashion based on the parent node and with 70% maximum extent of the box

Kd-tree Notes There exist many variants: kd-tree, adaptive kd-tree, fair-split tree, VAMSplit kd-tree, minimum-ambiguity kd-tree, bucket generalized pseudo kd-tree, bucket adaptive kd-tree, PR kd-tree etc. The way of selection partitioning plane position and orientation is crucial for performance of the data structures The selection of the appropriate variant is application dependent

Example: Sliding-Midpoint kd-tree Efficient for range searching and kNN searching (in the lecture 6/7)

Sliding-Midpoint Kd-tree Partitioning plane in the middle: Points on both side: nothing happens Point on one side only: slide the partitioning plane to the nearest data point

Examples of Other Data Structures A content of the interior node can be anything ! Binary space partitioning tree (2D/3D) – general plane D-tree – general polyline in 2D

Binary Space Partitioning (BSP) trees General partitioning planes, not aligned with main coordinate system Note: in computer graphics often used for triangle-based scenes.

D-trees For 2D: partitioning by polylines

Compression Methods for Point-Based Data Structures Quantization of the partitioning plane – do not store the partitioning plane by floating point representation, but say where it is in the box relatively using limited number of positions: 0 1 2 3 4 5 6 7

Compression Methods for Point-Based Data Structures Quantization of data positions (MX-trees) Round-robin fashion: if we use x,y,z,x,y… fashion in regular way, we may not need to store the axis orientation in the interior nodes. Implicit pointers: for depth-first-search (DFS) storage of interior nodes in the memory

Method of Implicit Pointers Saving one pointer in each interior node Address in memory: A1, A2, A3 Size of the node is fixed: S bytes A1 data L R A data R A2 data L R A+S data R A+2.S data R A3 data L R

Implicit pointers on 32-bit computers The addresses have to be aligned: A mod 8 = A 3 bits – type of the node (8 possibilities) Leaf node 7 types of interior nodes 29 bits as pointer to the right child Left child pointed explicitly by address A+8 In 32 bits can be used to store the position of the splitting plane (for kd-trees) or several quantized positions for octrees etc. Interior nodes/leaves need then only 8 Bytes! A tree has to be constructed in DFS order

Practical Recommendations for Data Structures over Point Data First, use a kd-tree, with appropriate representation in the memory Sliding-midpoint kd-tree Implicit pointers Data only in leaves – fast insertion and deletion If the performance or storage space of kd-trees is insufficient, try to use a different data structure suitable to the task Uniform grids if data are known to be sufficiently uniform Octrees and quadtrees, different versions Special trees such as BSP-trees or D-trees if the data and searching algorithm fits to the task.

Thank you for your attention!