BSP trees
-
Upload
manishbhardwaj8131 -
Category
Documents
-
view
219 -
download
0
Transcript of BSP trees
-
7/27/2019 BSP trees
1/47
BSP Trees
Binary space partitioning trees.
Used to store a collection of objects in n-
dimensional space.
Tree recursively divides n-dimensional
space using (n-1)-dimensional hyperplanes.
-
7/27/2019 BSP trees
2/47
Space Partitioning
n-dimensional space
splitting hyperplane
(n-1)-dimensional
a1x1 + a2x2+ anxn + an+1 = 0
ax + by + c = 0 (2D)
ax+by+cz+d = 0 (3D)
-
7/27/2019 BSP trees
3/47
Space Partitioning
n-dimensional space +ve half spaceax + by + c > 0
ax+by+cz+d > 0
-ve half space
ax + by + c < 0
ax+by+cz+d < 0
coincident
ax + by + c = 0
ax+by+cz+d = 0
-
7/27/2019 BSP trees
4/47
Classifying Objectz
In 2D,ph is the line ax + by + c = 0.
Compute ax + by + c for all vertices ofz.
If all values are = 0;zis coincident to ph.
If all values are = 0;zis right ofph.
Otherwise,zspansph and is to be split byfinding intersection points withph.
-
7/27/2019 BSP trees
5/47
2D
a
b
c
d
g
e
f
h
Equation ofph is
x
6 = 06
-
7/27/2019 BSP trees
6/47
2D
a
b
c
d
g
e
f
h
Equation ofph is
y
x
2 = 0
2
-
7/27/2019 BSP trees
7/47
3D
x
z
y
Equation ofph is
z2 = 0
General: ax + by + cz+ d= 0
-
7/27/2019 BSP trees
8/47
Space Partitioning
n-dimensional space
-ve +ve
-ve
+ve
coincident list
-
7/27/2019 BSP trees
9/47
Objects in 2D
a
b
c
d
g
e
f
h
-
7/27/2019 BSP trees
10/47
Objects in 2D
a
b
c
d
g
e
f
h
-
7/27/2019 BSP trees
11/47
Objects in 2D
a
b
c
d
g
e
f
h
a-d e-h
-
7/27/2019 BSP trees
12/47
Objects in 2D
a
b
c
d
g
e
f
h
a-d e-h
-
7/27/2019 BSP trees
13/47
Objects in 2D
a
b
c
d
g
e
f
h
a-b e-fc-d g-h
-
7/27/2019 BSP trees
14/47
Objects in 2D
a
b
c
d
g
e
f
h
a bc de f
g h
-
7/27/2019 BSP trees
15/47
Collision Detection
a
b
c
d
g
e
f
h
a bc de f
g h
-
7/27/2019 BSP trees
16/47
Visibility Ordering
a
b
c
d
g
e
f
h
a bc de f
g h
-
7/27/2019 BSP trees
17/47
BSP Tree Construction
Select partitioning hyperplanes.
Partition objects.
Repeat on partitions.
-
7/27/2019 BSP trees
18/47
Partitioning Hyperplane Selection
Face of an object.
a
b
c
d
g
e
f
h
-
7/27/2019 BSP trees
19/47
Partitioning Hyperplane Selection
Face of an object.
a
b
c
d
g
e
f
h
-
7/27/2019 BSP trees
20/47
Autopartition
Only object
faces are used assplitting
hyperplanes
a
b
c
d
g
e
f
h
-
7/27/2019 BSP trees
21/47
Partitioning Hyperplane Selection
Axis-aligned orthogonalhyperplanes
a
b
c
d
g
e
f
h
-
7/27/2019 BSP trees
22/47
Partitioning Hyperplane Selection
Axis-aligned orthogonalhyperplanes
a
b
c
d
g
e
f
h
-
7/27/2019 BSP trees
23/47
Partitioning Hyperplane Selection
Balance # objects (pieces) oneach side of hyperplane
Minimize increase in numberof objects/pieces.
a
b
c
d
g
e
f
h
-
7/27/2019 BSP trees
24/47
3D Example
-
7/27/2019 BSP trees
25/47
3D Example
-
7/27/2019 BSP trees
26/47
3D Example
-
7/27/2019 BSP trees
27/47
3D Example
-
7/27/2019 BSP trees
28/47
Another 3D Example
-
7/27/2019 BSP trees
29/47
Another 3D Example
-
7/27/2019 BSP trees
30/47
BSP Tree of an Object
Each leaf represents a region that is either wholly inside oroutside the object.
Object surface is considered inside object.
Surface planes are used as partitioning planes.
Orient partitioning hyperplanes so that interior is to left.
a
a
-
7/27/2019 BSP trees
31/47
BSP Tree of an Object
Each leaf represents a region that is either wholly inside oroutside the object.
Object surface is considered inside object.
Surface planes are used as partitioning planes.
Orient partitioning hyperplanes so that interior is to left.
a
a
b
b
-
7/27/2019 BSP trees
32/47
BSP Tree of an Object
Each leaf represents a region that is either wholly inside oroutside the object.
Object surface is considered inside object.
Surface planes are used as partitioning planes.
Orient partitioning hyperplanes so that interior is to left.
a
a
b
b
c
c
-
7/27/2019 BSP trees
33/47
BSP Tree of an Object
Each leaf represents a region that is either wholly inside oroutside the object.
Object surface is considered inside object.
Surface planes are used as partitioning planes.
Orient partitioning hyperplanes so that interior is to left.
a
a
b
b
c
c
dd
-
7/27/2019 BSP trees
34/47
BSP Tree of an Object
Each leaf represents a region that is either wholly inside oroutside the object.
Object surface is considered inside object.
Surface planes are used as partitioning planes.
Orient partitioning hyperplanes so that interior is to left.
a
a
b
b
c
d
ed
e
c
-
7/27/2019 BSP trees
35/47
BSP Tree of an Object
Each leaf represents a region that is either wholly inside oroutside the object.
Object surface is considered inside object.
Surface planes are used as partitioning planes.
Orient partitioning hyperplanes so that interior is to left.
a
a
b
b
c
df
ed
c
fe
-
7/27/2019 BSP trees
36/47
BSP Tree of an Object
Orient partitioning hyperplanes so that interior is to left.
With this orientation, left leaves are interior and
right leaves are exterior.
a
a
b
b
c
df
ed
ef
c
-
7/27/2019 BSP trees
37/47
BSP Tree Construction
Node structure:
ph = equation of partitioning hyperplane
cList= list of objects coincident withph
leftChild
rightChild
-
7/27/2019 BSP trees
38/47
BSP Tree ConstructionBSPtree(O)
// O is object set
ifO is empty, return null;
Create a new nodeN;
N.ph = partitioning hyperplane forO;
lList = rList = N.cList = null;
for each objectzin O do
ifzis coincident toph or|O| = 1, addztoN.cList;
ifzis left ofph, addzto lList;
ifzis right ofph, addzto rList;ifzspansph, splitzand add pieces to lListand rList;
N.leftChild = BSPTree(lList);
N.rightChild = BSPTree(rList);
return N;
-
7/27/2019 BSP trees
39/47
Basic Draw Back to Front
draw(N)
ifeye left ofN.ph
{draw(N.rightChild); draw N.cList; draw(N.leftChild)};
else ifeye right ofN.ph
{draw(N.leftChild); draw N.cList; draw(N.rightChild)};
else // eye coincident toN.ph{draw(N.leftChild); draw(N.rightChild)};
-
7/27/2019 BSP trees
40/47
Basic Draw Front to Back
draw(N)
ifeye left ofN.ph
{draw(N.leftChild); draw N.cList; draw(N.rightChild)};
else ifeye right ofN.ph
{draw(N.rightChild); draw N.cList; draw(N.leftChild)};
else // eye coincident toN.ph{draw(N.rightChild); draw(N.leftChild)};
-
7/27/2019 BSP trees
41/47
Randomization
Autopartition.
Splitting hyperplane is randomly selected to beone of the object faces.
Lines in 2D; planes in 3D.
a
b
g
e
h
-
7/27/2019 BSP trees
42/47
Randomization2D Analysis Start with n (nonintersecting) line segments.
Total number of line segments in autopartition bspis expected to be
-
7/27/2019 BSP trees
43/47
So, number of nodes in bsp is O(n log n).
Construction time at each node is O(n) as at eachnode O(n) segments need to be partitioned.
Time is O(n2log n) per construction round.
2 rounds expected.
Expected complexity is O(n2log n).
Randomization2D Analysis
8
3
8
4
6
n = 29
-
7/27/2019 BSP trees
44/47
Randomization3D Analysis
Start with n (nonintersecting) triangles. Total number of triangles in autopartition bsp is
O(n2).
There exist n-triangle examples for which every
autopartition has W(n2) triangles.
n = 24
-
7/27/2019 BSP trees
45/47
Free Partitions
One that does not split an object. Do a free partition whenever possible;
otherwise, randomly select a segment/face
as partitioning hyperplane.
8
3
8
4
6
-
7/27/2019 BSP trees
46/47
Free Partitions
Using an object face, that crosses a BSPregion, results in a free partition of that BSP
region.
Portion of black segment
bounded by red
(previous) splitting lines
may be used to partition
blue region. No segments
in blue region can be split
as line segments are non-
intersecting.
-
7/27/2019 BSP trees
47/47
Free Partitions
Using an object face, that crosses a BSPregion, results in a free partition of that BSP
region.
When green segment is
used to partition blue
region, segments in blue
region may be split.