Skip to content

Commit

Permalink
now using barnes-hut for repulsion calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
samizdatco committed Jan 17, 2011
1 parent f945392 commit aaeb2df
Show file tree
Hide file tree
Showing 19 changed files with 511 additions and 41 deletions.
16 changes: 16 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Arbor.js Changes
----------------


Version 0.91 | 17 jan 2011
--------------------------

* Now supplementing brute-force repulsion calculations with the more-efficient
(but noisier) barnes-hut algorithm. Use the ParticleSystem's .precision
parameter to control the accuracy/speed trade-off.


Version 0.9 | 12 jan 2011
-------------------------

* Initial release
23 changes: 22 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,25 @@ Getting Started

The docs folder contains a sample project that demonstrates some of the
basic idioms for working with the library to build a visualization. More
detailed documentation can be found at http://arborjs.org/reference
detailed documentation can be found at http://arborjs.org/reference.

Colophon
--------

Arbor’s design is heavily influenced by Jeffrey Bernstein’s excellent
Traer Physics[1] library for Processing. In addition, much of the
physics code has been adapted from Dennis Hotson’s springy.js[2]. The
Barnes-Hut n-body implementation is based on Tom Ventimiglia and Kevin
Wayne’s vivid description[3] of the algorithm.

Thanks to all for releasing such elegantly simple and comprehensible
code.

[1] <http://murderandcreate.com/physics/>
[2] <https://github.com/dhotson/springy>
[3] <http://arborjs.org/docs/barnes-hut>

License
-------

Arbor is released under the MIT license. http://en.wikipedia.org/wiki/MIT_License
5 changes: 2 additions & 3 deletions build/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
def make_lib():
if not os.path.exists('lib'): os.mkdir('lib')
targets = {
"arbor.js": ["etc.js", "kernel.js", "physics/atoms.js", "physics/system.js", "physics/physics.js" ],
"arbor.js": ["etc.js", "kernel.js", "physics/atoms.js", "physics/system.js", "physics/barnes-hut.js", "physics/physics.js" ],
"arbor-tween.js": ["etc.js","graphics/colors.js", "tween/easing.js", "tween/tween.js"],
"arbor-graphics.js": ["etc.js", "graphics/colors.js", "graphics/primitives.js", "graphics/graphics.js" ],
}
Expand Down Expand Up @@ -203,10 +203,9 @@ def main():
if should_get.lower().startswith('y'):
get_yui()
else:
print "Please adjust the YUI_PATH variable in the script to point to the proper command"
sys.exit(1)
YUI_PATH = os.path.abspath('./yui')
# print "Please adjust the YUI_PATH variable in the script to point to the proper command"
# sys.exit(1)

os.chdir("%s/.."%os.path.dirname(os.path.abspath(__file__)))
make_lib()
Expand Down
2 changes: 1 addition & 1 deletion build/tmpl/arbor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// arbor.js - version 0.5
// arbor.js - version 0.91
// a graph vizualization toolkit
//
{{LICENSE}}
Expand Down
16 changes: 16 additions & 0 deletions build/tmpl/changes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Arbor.js Changes
----------------


Version 0.91 | 17 jan 2011
--------------------------

* Now supplementing brute-force repulsion calculations with the more-efficient
(but noisier) barnes-hut algorithm. Use the ParticleSystem's .precision
parameter to control the accuracy/speed trade-off.


Version 0.9 | 12 jan 2011
-------------------------

* Initial release
23 changes: 22 additions & 1 deletion build/tmpl/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,25 @@ Getting Started

The docs folder contains a sample project that demonstrates some of the
basic idioms for working with the library to build a visualization. More
detailed documentation can be found at http://arborjs.org/reference
detailed documentation can be found at http://arborjs.org/reference.

Colophon
--------

Arbor’s design is heavily influenced by Jeffrey Bernstein’s excellent
Traer Physics[1] library for Processing. In addition, much of the
physics code has been adapted from Dennis Hotson’s springy.js[2]. The
Barnes-Hut n-body implementation is based on Tom Ventimiglia and Kevin
Wayne’s vivid description[3] of the algorithm.

Thanks to all for releasing such elegantly simple and comprehensible
code.

[1] <http://murderandcreate.com/physics/>
[2] <https://github.com/dhotson/springy>
[3] <http://arborjs.org/docs/barnes-hut>

License
-------

Arbor is released under the MIT license. http://en.wikipedia.org/wiki/MIT_License
1 change: 0 additions & 1 deletion demos/atlas/atlas.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
ctx.fillText(label||"", pt.x, pt.y+4)
}
})

},

resize:function(){
Expand Down
2 changes: 1 addition & 1 deletion demos/echolalia/echolalia.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
}

$(document).ready(function(){
var sys = arbor.ParticleSystem(1000, 1000, 0.5) // create the system with sensible stiffness/repulsion/friction
var sys = arbor.ParticleSystem(1000, 800, 0.5) // create the system with sensible repulsion/stiffness/friction
sys.renderer = DeadSimpleRenderer("#viewport") // our newly created renderer will have its .init() method called shortly by sys...

// pick a random datafile and load it
Expand Down
4 changes: 2 additions & 2 deletions demos/echolalia/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<a class="another" href="#">see another »</a>
<div id="label"><span></span> <a target="_blank" href="http://samizdat.cc/projects/echolalia/final/">about...</a></div>

<script src="../_/jquery.1.4.4.min.js"></script>
<script src="../../lib/arbor.js"></script>
<script src="../..../_/jquery.1.4.4.min.js"></script>
<script src="../../lib/arbor.js"></script>
<script src="echolalia.js"></script>

</body>
Expand Down
2 changes: 1 addition & 1 deletion demos/halfviz/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1>about <a href="#">&times;</a></h1>
AT&amp;T’s <em>Nevermind</em>-era, C-language classic <a target="_blank" href="http://graphviz.org">GraphViz</a>.</p>
<p>It takes one of the central good ideas of GraphViz – the <code><a target="_blank" href="http://graphviz.org/doc/info/lang.html">.dot</a></code>
graph description language – and scales things back in the name of simplicity of implementation
and brevity of syntax. Remember, <a target="_blank" href="http://www.instapaper.com/go/111151108/text">worse is better</a> these days.</p>
and brevity of syntax. Remember, <a target="_blank" href="http://arborjs.org/docs/worse-is-better">worse is better</a> these days.</p>
<p>The result is the <a href="#" class="help">halftone</a> language; a <code>dot</code>-inspired, mostly-declarative
format for describing graph relationships and styling the resulting nodes and edges.
</div>
Expand Down
2 changes: 1 addition & 1 deletion demos/halfviz/style/halfviz.css
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ a.update{

#intro{
position:fixed;
top:80px;
top:68px;
left:20px;
z-index:2;
display:none;
Expand Down
184 changes: 184 additions & 0 deletions docs/_/ref.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/* http://meyerweb.com/eric/tools/css/reset/
v1.0 | 20080212 */

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
body {
line-height: 1;
}
ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}

/* remember to define focus styles! */
:focus {
outline: 0;
}

/* remember to highlight inserts somehow! */
ins {
text-decoration: none;
}
del {
text-decoration: line-through;
}

/* tables still need 'cellspacing="0"' in the markup */
table {
border-collapse: collapse;
border-spacing: 0;
}

/* end css reset */



body{
font-family: "athelas-1","athelas-2",serif;
font-size:18px;
line-height:23px;
color:#330;
margin:40px 80px;
}

#doc{
width:530px;
margin:0 auto;
}

#doc > img{
/* position:absolute;
left:40px;
*/}

p{
margin-bottom:.5em;
}

h2{
margin:3em 0 0 0;
text-transform:uppercase;
font-weight:bold;
font-size:80%;
color:#AD621C;
}

h3{
margin:1em 0 0 0;
}

.poetry + p,
h3 + p,
h2 + p{
text-indent:0;
}


ol{
margin:0 0 0 0em;
}
ul{
margin:.25em 0 .25em 1em;
}
li{
font-style:italic;
margin-bottom:.5em;
}

li span{
text-transform:uppercase;
font-weight:bold;
font-style:normal;
font-size:70%;
letter-spacing:1px;
display:block;
}

ol img{
margin-left:-18px;
}

ol em{
/* font:bold 13px Arial; */
/* text-transform:uppercase;*/
}

.poetry{
font-style:italic;
margin:.25em 0 .75em 1em;
}

.eg{
margin-left:1em;
margin-right:3em;
font-size:16px;
font-style:italic;
}

#titleblock{
font:12px/25px Helvetica, Arial, sans-serif;
margin-bottom:2em;
color:#666;
}
#titleblock h1{
font-weight:normal;
font-size:24px;
color:#333;
}

#titleblock p{
font-family: "athelas-1","athelas-2",serif;
text-transform:uppercase;
font-weight:bold;
letter-spacing:1px;
}

#attrib{
font:14px/19px Helvetica, Arial, sans-serif;
border-top:1px solid #aaa;
margin-top:2em;
padding-top:3px;
}
a{
color:#AD621C;
text-decoration:none;
}

a:hover{
text-decoration:underline;
}

code{
font:13px/23px Monaco, "Andale Mono", monospace;
}
.math{
margin:0 0 1em 2em;
font:13px/23px Monaco, "Andale Mono", monospace;
}




5 changes: 3 additions & 2 deletions docs/reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h2><a href="#">&times;</a> creation</h2>
<p>Parameters for the physics simulation can be set at creation-time
by calling the constructor with the arguments:</p>
<p class="code">
arbor.ParticleSystem(repulsion, stiffness, friction, gravity, fps, dt)
arbor.ParticleSystem(repulsion, stiffness, friction, gravity, fps, dt, precision)
</p>
<p>The parameters and their defaults are:</p>
<ul>
Expand All @@ -36,7 +36,8 @@ <h2><a href="#">&times;</a> creation</h2>
<li><em>gravity </em><b>false</b> an additional force attracting nodes to the origin </li>
<li><em>fps </em><b>55</b> frames per second </li>
<li><em>dt </em><b>0.02</b> timestep to use for stepping the simulation </li>

<li><em>precision </em><b>0.6</b> accuracy vs. speed in force calculations<br>
<em>&nbsp;</em><b>&nbsp;</b> (zero is fast but jittery, one is smooth but cpu-intensive)</li>
</ul>
<p>The defaults will be used for any omitted arguments. Parameters can also be passed
in an object literal. For reference, the following calls are all equivalent:</p>
Expand Down
15 changes: 8 additions & 7 deletions lib/arbor.js

Large diffs are not rendered by default.

Loading

0 comments on commit aaeb2df

Please sign in to comment.