MCPcopy Create free account
hub / github.com/breck7/scroll / place

Function place

external/.d3.js:13415–13437  ·  view source on GitHub ↗
(b, a, c)

Source from the content-addressed store, hash-verified

13413}
13414
13415function place(b, a, c) {
13416 var dx = b.x - a.x, x, a2,
13417 dy = b.y - a.y, y, b2,
13418 d2 = dx * dx + dy * dy;
13419 if (d2) {
13420 a2 = a.r + c.r, a2 *= a2;
13421 b2 = b.r + c.r, b2 *= b2;
13422 if (a2 > b2) {
13423 x = (d2 + b2 - a2) / (2 * d2);
13424 y = Math.sqrt(Math.max(0, b2 / d2 - x * x));
13425 c.x = b.x - x * dx - y * dy;
13426 c.y = b.y - x * dy + y * dx;
13427 } else {
13428 x = (d2 + a2 - b2) / (2 * d2);
13429 y = Math.sqrt(Math.max(0, a2 / d2 - x * x));
13430 c.x = a.x + x * dx - y * dy;
13431 c.y = a.y + x * dy + y * dx;
13432 }
13433 } else {
13434 c.x = a.x + c.r;
13435 c.y = a.y;
13436 }
13437}
13438
13439function intersects(a, b) {
13440 var dr = a.r + b.r - 1e-6, dx = b.x - a.x, dy = b.y - a.y;

Callers 3

DisplayFunction · 0.70
NativeScrollbarsFunction · 0.70
packSiblingsRandomFunction · 0.70

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected