You are on page 1of 28

Mesh Generation

Quadtrees

Geometric Algorithms

Lecture 9: Quadtrees

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

VLSI Design

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Finite Element Method

http://www.antics1.demon.co.uk/finelms.html

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Meshes

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Meshes

not conforming
component

not well-shaped
doesn’t respect input

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Meshes

Input: disjoint polygonal objects


integer coordinates
U
0, 45, 90, 135 degree angles

0
0 U

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Meshes

Input: disjoint polygonal objects


integer coordinates
not conforming
0, 45, 90, 135 degree angles component
Output: triangular mesh
conforming: no vertices in the
interior of edges
respecting the input: input
edges contained in mesh edges
well-shaped: triangle angles at not well-shaped
least 45 degrees doesn’t respect input

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Steiner points

without Steiner points angles in triangles can be very small

Example: Triangulation that maximizes the minimum angle


has a minimum angle of 5 degrees

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Uniform vs. Non-uniform Meshes

uniform non-uniform

512 triangles 52 triangles

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Quadtrees
Quadtree: a rooted tree in which every node has 4 children
each node corresponds to a square in the plane
each child of a node corresponds to a quadrant of the
square of the node
a quadtree induces a subdivision of the square of the root

NE NW SW SE

can be used for efficient storing of non-uniform meshes


Geometric Algorithms Lecture 9: Quadtrees
Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Quadtree Examples

http://donar.umiacs.umd.edu/quadtree/, in particular
http://donar.umiacs.umd.edu/quadtree/points/prquad.html
http://www.maptiler.org/
google-maps-coordinates-tile-bounds-projection/

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Constructing a Quadtree

can store different types of data; here: point sets


Principle: split squares until each square contains ≤ 1 point
Recursive Construction:
start with square containing all
points;
if there is more than 1 point in the
square then
split square into 4 quadrants
assign points to squares
recur on each of the quadrants

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Constructing a Quadtree

can store different types of data; here: point sets


Principle: split squares until each square contains ≤ 1 point
Recursive Construction:
start with square containing all
points;
if there is more than 1 point in the σNW σNE
square then ymid
split square into 4 quadrants σSW σSE
assign points to squares
recur on each of the quadrants xmid

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Unbalanced Quadtrees

quadtrees become unbalanced when many points lie close together

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Side lengths

side lengths of squares in a quadtree halve with increasing depth

side length = s/8

depth = 3
s

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Properties

Lemma: Let c be the smallest distance between any two points


in a point set P , and let s be the side length of the
initial (biggest) square. Then the depth of a quadtree
for P is at most log(s/c) + 3/2.

Lemma: A quadtree of depth d storing n points has


O((d + 1)n) nodes and can be constructed in
O((d + 1)n) time.

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Finding a Neighbor

quadtree is a subdivision into regions


typical operation: moving around among regions

Neighbor finding: Given a node v (a square) and a direction


(north, south, west, or east), which node (square) is adjacent
to v in the given direction?

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Algorithm for Finding a Neighbor

Input: a node v in a quadtree T


Output: north neighbor of v north-neighbor of parent(ν)

if v is a SW- or SE-child, then its


north neighbor is a sibling
otherwise, climb T until a node w is
reached that is a SW- or SE-child
if this does not exist, return nil σ (ν)

... and descend down into the north


neighbor of w finding the SW or SE
nod at the same depth as v.
this also works for south, west, east
running time: O(d + 1) time in a quadtree of depth d

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Algorithm for Finding a Neighbor

Input: a node v in a quadtree T


Output: north neighbor of v north-neighbor of parent(ν)

if v is a SW- or SE-child, then its


north neighbor is a sibling
otherwise, climb T until a node w is
reached that is a SW- or SE-child
if this does not exist, return nil σ (ν)

... and descend down into the north


neighbor of w finding the SW or SE
nod at the same depth as v.
this also works for south, west, east
running time: O(d + 1) time in a quadtree of depth d

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Algorithm for Finding a Neighbor

Input: a node v in a quadtree T


Output: north neighbor of v north-neighbor of parent(ν)

if v is a SW- or SE-child, then its


north neighbor is a sibling
otherwise, climb T until a node w is
reached that is a SW- or SE-child
if this does not exist, return nil σ (ν)

... and descend down into the north


neighbor of w finding the SW or SE
nod at the same depth as v.
this also works for south, west, east
running time: O(d + 1) time in a quadtree of depth d

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Balanced Quadtrees

a quadtree is balanced if any two neighboring nodes differ at


most 1 in depth

an unbalanced quadtree subdivision

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Balancing a Quadtree

add nodes!

balancing

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Algorithm for Balancing a Quadtree

Input: quadtree T
Output: balanced version of T
1. insert all leaves of T into a linear list L
2. while L is not empty
3. do remove a leave µ from L
4. if σ(µ) has to be split
5. then make µ an internal node with 4 children;
if µ stores a point, store it in the correct leave
6. insert the 4 new leaves into L
7. check if σ(µ) had neighbors that now need to be split,
and if so, insert them into L
8. return T

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

Complexity of a balanced Quadtree

Theorem: Let T be a quadtree with m nodes. Then the


balanced version of T has O(m) nodes and can be
constructed in O((d + 1)m) time.

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

From Quadtrees to Meshes

Input: grid with 2j × 2j squares and a set U


of disjoint polygonal objects inside (integer
coord.; 0, 45, 90, 135 degree angles)

Output: triangular mesh of the inside and


outside of the objects inside the square
that is conforming, well-shaped,
0
non-uniform, and respects the input. 0 U

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

From Quadtrees to Meshes

build a quadtree:
split until no object intersects a square
or square has size 1 × 1
this gives small squares at objects,
(and larger ones further away)
an object completely in the square and even a single point of
intersection count as intersections!

Geometric Algorithms Lecture 9: Quadtrees


Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

From Quadtrees to Meshes

an edge of an object can only cross a square as a diagonal


make the quadtree balanced
add a Steiner point in the middle and produce triangles
where needed

triangular mesh is stored as doubly-connected edge list


Geometric Algorithms Lecture 9: Quadtrees
Motivation
Meshes
Mesh Generation
Quadtrees
QuadtreesToMeshes

From Quadtrees to Meshes

Theorem: Let S be a set of disjoint polygonal objects with


vertices on a (integer) grid [0, U ] × [0, U ]. Then
there exists a non-uniform triangular mesh for S that is
conforming, well-shaped and respects the input
the number of triangles is O(p(S) log U ), where p(S) is
the sum of (lengths of) perimeters of the objects
the mesh can be constructed in O(p(S) log2 U ) time

Geometric Algorithms Lecture 9: Quadtrees

You might also like