<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="presentation.css" type="text/css"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="stylesheet" href="presentation.css" type="text/css" />
<script type="text/javascript" src="presentation.js"></script>
<title>GraphGrow</title>
</head>
<body onload="initialize();">

<!-- ####################################################################### -->

<div id="menu">
<ul>
<li>Introduction</li>
<li><a href="javascript:show('demo');">Demo</a></li>
<li><a href="javascript:show('sheep');">Sheep</a></li>
<li><a href="javascript:show('ifs');">IFS</a></li>
<li><a href="javascript:show('gdifs');">GDIFS</a></li>

<li>Mathematics</li>
<li><a href="javascript:show('dimension');">Fractals</a></li>
<li><a href="javascript:show('covering');">Ball Covering</a></li>
<li><a href="javascript:show('hausdorffinformal');">Hausdorff</a></li>
<li><a href="javascript:show('kochdim1');">Example (1)</a></li>
<li><a href="javascript:show('kochdim2');">Example (2)</a></li>
<li><a href="javascript:show('gdifsdim');">GDIFS Dimension</a></li>
<li><a href="javascript:show('opensets');">Open Problems</a></li>

<li>Interactive</li>
<li><a href="javascript:show('whatissvg');">What Is SVG?</a></li>
<li><a href="javascript:show('dsvg');">Dynamic SVG</a></li>
<li><a href="javascript:show('isvg');">Interactive SVG</a></li>

<li>Engine</li>
<li><a href="javascript:show('rendermethods');">Render Methods</a></li>
<li><a href="javascript:show('oversampling');">Oversampling</a></li>
<li><a href="javascript:show('homogeneous1');">Homogeneous (1)</a></li>
<li><a href="javascript:show('homogeneous2');">Homogeneous (2)</a></li>
<li><a href="javascript:show('scenelang');">Scenes</a></li>
<li><a href="javascript:show('piping');">Pipelines</a></li>

<li>Concluding</li>
<li><a href="javascript:show('videos');">Videos</a></li>
<li><a href="javascript:show('theend');">The End</a></li>
</ul>
</div>

<!-- ####################################################################### -->

<div id="main"><h1>GraphGrow</h1>

<!-- ####################################################################### -->

<div class="page" id="title">
<p><img src="graphgrow-logo.png" /></p>
</div>

<!-- ####################################################################### -->

<div class="page" id="demo">

<h2>Demonstration</h2>

<p>A video showing GraphGrow in action should be gracing this screen shortly.</p>

</div>

<!-- ####################################################################### -->

<div class="page" id="sheep">

<h2>The Competition:<br />www.electricsheep.org</h2>

<p>Animates <strong>"fractal flames"</strong> (a type of iterated function system) using a <strong>"chaos game"</strong> method.</p>
<p>Looks nice enough, but...</p>

<h1>Re-invent the wheel...<br />...only squarer!</h1>

<ul>
<li>Interactive design and analysis.<br /><strong>graphgrow.svg</strong></li>
<li>Recursive renderer.<br /><strong>graphgrow-engine.c</strong></li>
<li>Pipeline architecture.<br /><strong>./parameters | ./calculations | ./make-scene |<br />graphgrow-engine | ppmtoy4m | mpeg2enc</strong></li>
</ul>

</div>

<!-- ####################################################################### -->

<div class="page" id="ifs">

<h2>Iterated Function Systems</h2>

<ul>
<li>Start from a <strong>seed</strong>.</li>
<li>Apply a set of <strong>rules</strong>.</li>
<li>Rinse, <strong>repeat</strong> as required.</li>
</ul>

<p><img src="koch-sequence.png" /></p>

</div>

<!-- ####################################################################### -->

<div class="page" id="gdifs">

<h2>Graph-Directed IFS</h2>

<ul>
<li>Not all rules need be applied at each step.</li>
<li><strong>Directed graph</strong> controls ("<strong>directs</strong>") rules.</li>
</ul>

<p><img src="gdifs.png" /></p>

</div>

<!-- ####################################################################### -->

<div class="page" id="dimension">

<h2>Fractal Dimension</h2>

<p><strong>Topological</strong> dimension is a natural number that describes
<strong>"how connected"</strong> a set is.</p>

<p>For example a collection of disconnected points has a topological dimension
of 0 and a connected area has a topological dimension of 2.</p>

<p><strong>Hausdorff</strong> dimension is a non-negative real number that
refines the concept of topological dimension, and also relates it to other
properties of space such as area or volume.</p>

<p><strong>Fractals</strong> have Hausdorff dimension greater than their
topological dimension, most often with a fractional part.</p>

</div>

<!-- ####################################################################### -->

<div class="page" id="covering">

<h2>Ball Covering</h2>

<ul>
<li>Covering a shape with <strong>smaller balls</strong> requires <strong>more balls</strong>.</li>
<li><strong>"How many more"</strong> is one way to measure <strong>fractal dimension</strong>.</li>
</ul>

<p><img src="covering.gif" /></p>

</div>

<!-- ####################################################################### -->

<div class="page" id="hausdorffinformal">

<h2>Hausdorff Dimension: Informally</h2>

<ul>
<li><strong>X</strong> is the fractal shape to measure.</li>
<li><strong>r</strong> is the size of each ball, which is reduced towards 0.</li>
<li><strong>N<sub>r</sub>(X)</strong> is the number of balls of that size required to cover the shape.</li>
<li><strong>d</strong> is the dimension to calculate.</li>
</ul>

<p><img src="hausdorff-informal.png" /></p>

<p>The formal definition of Hausdorff Dimension is rather more involved!</p>

</div>

<!-- ####################################################################### -->

<div class="page" id="kochdim1">

<h2>Dimension Calculation (1)</h2>

<p>Given the curve definition:</p>

<p><img src="koch-dim-1.png" /></p>

<p>Solve this equation for <strong>d</strong>:</p>

<p><img src="koch-dim-2.png" /></p>

</div>

<!-- ####################################################################### -->

<div class="page" id="kochdim2">

<h2>Dimension Calculation (2)</h2>

<p>This can be done with the help of some logarithms:</p>

<p><img src="koch-dim-3.png" /></p>
<p><img src="koch-dim-4.png" /></p>
<p><img src="koch-dim-5.png" /></p>

<p>Approximately, <strong>d = 1.261859507...</strong></p>

</div>

<!-- ####################################################################### -->

<div class="page" id="gdifsdim">

<h2>GDIFS Dimension Calculation</h2>

<p><strong>Hausdorff Dimension in Graph Directed Constructions</strong><br />
R Daniel Mauldin &amp; S C Williams,
AMS Vol. 309, No. 2 (Oct. 1988), 811-829</p>

<p>The dimension of a graph-directed construction is the maximum of the
dimensions of each <strong>strongly connected component</strong>.  The
dimension of a SCC can be found by solving:</p>

<p><img src="gdifs-dim.png" /></p>

<p>Iterative numerical calculations can find approximate solutions.</p>

</div>

<!-- ####################################################################### -->

<div class="page" id="opensets">

<h2>Open Set Condition</h2>

<p>The calculated dimension is <strong>not always valid</strong>!</p>

<blockquote>For self-similar sets, the existence of a feasible open set is a
natural separation condition which expresses geometric as well as
measure-theoretic properties.</blockquote>

<p>The <strong>Open Set Condition</strong> tells when then dimension is valid,
but checking that it holds is <strong>non-trivial</strong> for anything beyond
1&nbsp;dimension.  (GraphGrow renders 2D fractals.)</p>

<p>Informally, if the Open Set Condition doesn't hold, then the fractal overlaps
with itself and the dimension calculations count the overlapped parts multiple
times, which is the wrong thing to do.</p>

<p><strong>On The Open Set Condition For Self-Similar Fractals</strong><br />
Christoph Bandt &amp; Nguyen Viet Hung &amp; Hui Rao, 2004-10-25</p>

<p>So, take the dimension calculations with a kilo of salt!</p>

</div>

<!-- ####################################################################### -->

<div class="page" id="whatissvg">

<h2>Scalable Vector Graphics</h2>

<p><b>eXtensible Markup Language</b> (<strong>XML</strong>).<br />
A grammar/syntax for structured documents.</p>
<p><b>Scalable Vector Graphics</b> (<strong>SVG</strong>).<br />
A vocabulary for describing vector graphics in XML.</p>
<p><b>Document Object Model</b> (<strong>DOM</strong>).<br />
A model of the document inside the browser.</p>
<p><b>Core Javascript</b> (<strong>ECMAScript</strong>).<br />
A scripting language that can manipulate the DOM.</p>
<p><b>User Input</b> (<strong>Event Model</strong>).<br />
Events (eg, mouse clicks) can trigger scripts.</p>

</div>

<!-- ####################################################################### -->

<div class="page" id="dsvg">

<h2>Dynamic SVG</h2>

<p>Use ECMAScript to manipulate the SVG DOM.</p>

<pre><span class="comment">// SVG uses this XML namespace.</span>
<span class="code">var ns = "http://www.w3.org/2000/svg";</span>
<span class="comment">// Create a new pane object.</span>
<span class="code">growPane = newPane();</span>
<span class="comment">// Create an SVG element to draw into.</span>
<span class="code">growPane.renderCanvas =
    SVGDocument.createElementNS(ns, "g");</span>
<span class="comment">// Link into the DOM, so it will be drawn.</span>
<span class="code">growPane.appendChild(growPane.renderCanvas);</span>
<span class="comment">// Arbitrary data can be embedded.</span>
<span class="comment">// Functions are values, and can be "anonymous".</span>
<span class="code">growPane.onActivate = function() {
    grow(growPane.renderCanvas);
};</span></pre>

<p>GraphGrow creates everything apart from the top level
<strong>&lt;svg&gt;</strong> element dynamically.</p>

</div>

<!-- ####################################################################### -->

<div class="page" id="isvg">

<h2>Interactive SVG</h2>

<ul>
<li>User input triggers events in the browser.</li>
<li>These events can trigger script functions.</li>
<li>Scripts need to tell the browser which events each element responds to.</li>
</ul>

<pre><span class="comment">// What to do when a button is clicked.</span>
<span class="code">function buttonClick(evt) {
  activatePane(evt.currentTarget.button.pane);
  evt.stopPropagation();
}</span>
<span class="comment">// Tell the browser about that action.</span>
<span class="code">button.addEventListener(
  "click", buttonClick, false
);</span></pre>

<p>Drag-and-drop requires adding/removing listeners in response to events.</p>

<p>GraphGrow has some bugs in this area...</p>

</div>

<!-- ####################################################################### -->

<div class="page" id="rendermethods">

<h2>Rendering Methods</h2>

<ul>
<li><strong>Recursion</strong>:
explore all paths until the detail is too small to display.</li>
<li><strong>Chaos Game</strong>:
pick one long path at random until the image is dense enough.</li>
</ul>

<p><img src="recursion-vs-chaos.png" /></p>

</div>

<!-- ####################################################################### -->

<div class="page" id="oversampling">

<h2>Oversampling For Anti-Aliasing</h2>

<ul>
<li>Improves quality by smoothing irregularities.</li>
<li>Uses considerably more time and memory.</li>
</ul>

<p><img src="oversampling.png" /></p>

</div>

<!-- ####################################################################### -->

<div class="page" id="homogeneous1">

<h2>Homogeneous Coordinates (1)</h2>

<p>An <strong>affine transformation</strong> is a combination of rotation /
shearing / scaling (which can be represented by a 2x2 <strong>matrix
multiplication</strong>) and a translation (a <strong>vector
addition</strong>).</p>

<p><img src="homogeneous-1.png" /></p>

<p>Using <strong>3&nbsp;coordinates instead of 2</strong> makes the code
much simpler:</p>

<p><img src="homogeneous-2.png" /></p>

</div>

<!-- ####################################################################### -->

<div class="page" id="homogeneous2">

<h2>Homogeneous Coordinates (2)</h2>

<p>Two <strong>homogeneous</strong> points are equivalent when:</p>

<p><img src="homogeneous-3.png" /></p>

<p>Transformations are now just a 3x3 matrix multiplication:</p>

<p><img src="homogeneous-4.png" /></p>

<p>(With 9 parameters instead of 6, these are more general than affine
transformations which have g=0, h=0, i=1.)</p>

</div>

<!-- ####################################################################### -->

<div class="page" id="scenelang">

<h2>Scene Description Language</h2>

<p>scene <b>::=</b> <strong>GG0 [</strong> rules <strong>]</strong></p>

<p>rule <b>::=</b> node <strong>&gt;-[</strong> transformation <strong>|</strong> colour <strong>]-&gt;</strong> node</p>

<p>Example (<strong>echo "1.7" | ./spiral</strong>):</p>

<pre class="small"><b>GG0 [</b>
  0 <b>&gt;-[</b>  5.493936680830965e-02,  1.563692725406522e-01,  0.000000000000000e+00,
        -1.563692725406522e-01,  5.493936680830965e-02,  0.000000000000000e+00,
         0.000000000000000e+00,  0.000000000000000e+00,  1.000000000000000e+00
      <b>|</b>  1.000000000000000e+00,  5.000000000000000e-01,  0.000000000000000e+00, 1.000000000000000e-01
      <b>]-&gt;</b> 0
  0 <b>&gt;-[</b>  8.901212663192369e-01, -3.127385450587679e-01,  5.493936680830965e-02,
         3.127385450587679e-01,  8.901212663192369e-01, -1.563692725406522e-01,
         0.000000000000000e+00,  0.000000000000000e+00,  1.000000000000000e+00
      <b>|</b>  0.000000000000000e+00,  5.000000000000000e-01,  1.000000000000000e+00, 5.000000000000000e-03
      <b>]-&gt;</b> 0
  0 <b>&gt;-[</b>  5.493936680830965e-02,  1.563692725406522e-01,  9.450606331916903e-01,
        -1.563692725406522e-01,  5.493936680830965e-02,  1.563692725406522e-01,
         0.000000000000000e+00,  0.000000000000000e+00,  1.000000000000000e+00
      <b>|</b>  1.000000000000000e+00,  5.000000000000000e-01,  0.000000000000000e+00, 1.000000000000000e-01
      <b>]-&gt;</b> 0
<b>]</b></pre>

<ul>
<li>GG0 format animations are just a sequence of scenes.</li>
<li>GG0 format is easy to write, and almost as easy to read.</li>
</ul>

</div>

<!-- ####################################################################### -->

<div class="page" id="piping">

<h2>Pipeline Architecture</h2>

<p>GraphGrow-Engine reads a sequence of <strong>GG0</strong> scenes from
<strong>stdin</strong> and writes a sequence of <strong>PPM</strong> images
on <strong>stdout</strong>.</p>

<p>Helper programs to manipulate parameters are similar:</p>

<pre><span class="comment">generate a line with 750 steps</span>
<span class="code">./line 1.001 1.86 750 |           </span>
<span class="comment">convert each number to a scene</span>
<span class="code">./spiral |                        </span>
<span class="comment">render scenes to images</span>
<span class="code">./graphgrow-engine 720 576 4 |    </span>
<span class="comment">convert images to YUV format</span>
<span class="code">ppmtoy4m -S 420mpeg2 -F 25:1 |    </span>
<span class="comment">encode to DVD-format MPEG video</span>
<span class="code">mpeg2enc -f 8 -a 2 -o spiral.m2v  </span></pre>

</div>

<!-- ####################################################################### -->

<div class="page" id="videos">

<h2>Videos</h2>

<p>Some videos rendered with GraphGrow-Engine should grace this screen shortly.</p>

</div>

<!-- ####################################################################### -->

<div class="page" id="theend">

<h2>The End</h2>

<p>That's it!</p>

<p>GraphGrow is online at:</p>

<h3>http://claudiusmaximus.goto10.org/GG/</h3>

</div>

<!-- ####################################################################### -->

</div>

<!-- ####################################################################### -->

<div id="foot">
<div style="float: left;">OpenLab4, London, UK</div>
<div style="float: right;">Claude Heiland-Allen
&lt;<a href="mailto:claudiusmaximus@goto10.org">claudiusmaximus@goto10.org</a>&gt;</div>
</div>

<!-- ####################################################################### -->

</body>
</html>

