<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" 
               "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd" [
  <!ENTITY mathml "http://www.w3.org/1998/Math/MathML">
]>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="../../../comsci/css/s011.css"/>
<link rel='SHORTCUT ICON' href='../../../comsci/images/FrameHome.ico' />
<style type="text/css">
</style>
<title> BSP Trees 
 </title>
</head>
<body>

<div class="message_right">
  <a href="http://validator.w3.org/check/referer">
    <img src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid
	XHTML 1.1!" height="31" width="88" />
  </a>

  <a href="http://jigsaw.w3.org/css-validator/">
    <img style="width:88px;height:31px"
       src="http://jigsaw.w3.org/css-validator/images/vcss" 
       alt="Valid CSS!" />
  </a>
  <br/>
  Created 2005-06-11 &nbsp; Modified 
<!--UPDATE_DATE_MODIFIED-->
<!--UPDATE_DATE_BEGIN-->
2007-01-01
<br/>
<a href="mailto:chelton.evans@yahoo.com">Chelton Evans</a>
<!--UPDATE_DATE_END-->
</div>


<h1> 
<a href="geom.html"> <img alt="proj" src="../../../comsci/images/compgeom.png" /></a>
BSP Trees
<a href="../../../../index.html">
<img alt="home" src="../../../comsci/images/Frame.gif" /> </a>
</h1>

<p>

<a href="#BSP">BSP</a><br/>
<a href="#Visible_Surface_Generation">
  Visible Surface Generation</a>
</p>


<div class="float25">
<a id="BSP"></a>
<h2>BSP</h2>

<p>Binary Space Partition Trees use 
<a href="g008.xml#Half-Spaces">Half-Spaces</a> to cut the space
 in half. This is applied recursively on the new branches. Each
 half space further sub-dividing the region in two.
</p>

<p>In two dimensions the cutter is a line.  Here is an example
 and the associated bsp tree.
</p>


<img src="diagg02901.png" alt="diagg02901.png" />

<p> If a line is visible to its parent line then the line
 appears
 on the rhs branch, else its on the left hand side branch.
</p> 

<p>
The leafs are the regions.  
</p>


</div>

<div class="float25">

<p>
Here I use points to construct the lines. 
 An arbitrary point of the remaining points was chosen to create 
 the  next partitions. The remaining points were divided
 according to which side of the line the points was on.
 <a href="g024.html">Quick Hull</a> uses a similar partitioning
 strategy.
</p>

<img src="diagg02902.png" alt="diagg02902.png" />

<p>
It is easy to test if a point is inside the region. Just follow
 the branch and if all the tests are satisfied then the point is 
 in the region. The test is a dot product of the point with the
 line (translating both to the origin first) &gt; 0.

</p>



</div>

<div class="spacer" />

<div class="float25">
<a id="Visible_Surface_Generation"></a>
<h2>Visible Surface Generation</h2>

<p>Consider a space with geometric objects made up of polygons.
 A BSP can partition or tessellate this space. For a static scene
 where the scene geometry does not change the tessellation can be
 used in the rendering process because the tessellation orders
 the polygons - literally a tessellation is an ordering.
</p>

<p>
Since the painters algorithm paints the objects furthest away first
 the tessellation is ideal.  The tessellation is transversed from furthest
 partitions to the nearest partitions.  
 Since this is represented in the BSP tree a fancy tree transversing
 algorithm is used.
</p>

<p>Since the geometry is static then the tree is static.  So the tree 
 transverse algorithm works on a static tree from any partition within
 the tree.  Since the tree/geometry is constructed once it is efficient.
</p>

<p>
"On Visible Surface Generation by a Priori Tree Structure" by H Fuchs, Z. Kedem and B. Naylor (1980 ACM 0-89791-021-4/80/0700) paper apparently introduced
 BSP trees for this. 
</p>

<p>This paper harps on about minimizing the number of polygons generated.
 When a polygon crosses a partition boundary it is split so that it lies
 distinctly in one of the partitions.  Such a minimization is extremely
 silly by to days standards but academics often waffle their papers and
 at the time there was justification because the hardware cost millions
 of dollars, but now we would not care about this.  Frankly I would not
 care about it then either.
</p>

<p>So when you read their paper you can see that their drama over
 "a large increase from the original number of polygons..." is a drama
 because the half space cuts maybe 20-30%.  This is insignificant when
 you look at the tools they bring out to deal with it. So this large 
 increase is a fiction.
</p>

<p>The paper is good and has other things I do not understand.</p>

<p>From what I gather BSP trees can be used in may ways. The paper separates
 the idea of fixed areas and replaces them with the geometric objects.
 And while polygons (and hence simplexes) make up a BSP trees objects,
 any geometric object can do.  If memory is not an issue the whole surface
 as simplexes could be in the tree.
</p>

<p>Given N geometric objects to be rendered transversing is O(N). ie we do
 not have to decide if object x is in front of y, so processing is linear.
</p>

<p>Other uses of the BSP tree could be used in conjunction with LOD to
 render the scene.
</p>

<p>No culling was done. &lt;TODO&gt; - read up on BSP trees and culling</p>


</div>





</body>
</html>


