| 9137 | } |
| 9138 | |
| 9139 | function initializeNodes() { |
| 9140 | for (var i = 0, n = nodes.length, node; i < n; ++i) { |
| 9141 | node = nodes[i], node.index = i; |
| 9142 | if (node.fx != null) node.x = node.fx; |
| 9143 | if (node.fy != null) node.y = node.fy; |
| 9144 | if (isNaN(node.x) || isNaN(node.y)) { |
| 9145 | var radius = initialRadius * Math.sqrt(0.5 + i), angle = i * initialAngle; |
| 9146 | node.x = radius * Math.cos(angle); |
| 9147 | node.y = radius * Math.sin(angle); |
| 9148 | } |
| 9149 | if (isNaN(node.vx) || isNaN(node.vy)) { |
| 9150 | node.vx = node.vy = 0; |
| 9151 | } |
| 9152 | } |
| 9153 | } |
| 9154 | |
| 9155 | function initializeForce(force) { |
| 9156 | if (force.initialize) force.initialize(nodes, random); |