MCPcopy Index your code
hub / github.com/clips/pattern / _distance

Method _distance

pattern/graph/__init__.py:625–635  ·  view source on GitHub ↗
(self, node1, node2)

Source from the content-addressed store, hash-verified

623 self.repulsion = 15 # Maximum repulsive force radius.
624
625 def _distance(self, node1, node2):
626 # Yields a tuple with distances (dx, dy, d, d**2).
627 # Ensures that the distance is never zero (which deadlocks the animation).
628 dx = node2._x - node1._x
629 dy = node2._y - node1._y
630 d2 = dx*dx + dy*dy
631 if d2 < 0.01:
632 dx = random() * 0.1 + 0.1
633 dy = random() * 0.1 + 0.1
634 d2 = dx*dx + dy*dy
635 return dx, dy, sqrt(d2), d2
636
637 def _repulse(self, node1, node2):
638 # Updates Node.force with the repulsive force.

Callers 2

_repulseMethod · 0.95
_attractMethod · 0.95

Calls 1

randomFunction · 0.85

Tested by

no test coverage detected