Published
Edited
Nov 30, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
/**
* Finds intersection point between two lines
* @param {Object} circleParams - Two circle parameters.
* @param {[cx:number,cy:number,r:number]} circleParams.c1 - cx,cy and r
* @param {[cx:number,cy:number,r:number]} circleParams.c2 - cx,cy and r
*/
function getRadicalAxisPoints({
c1,
c2,
}) {
const width = 1000;
const height = 1000;
let α1 = -2 * c1[0], β1 = -2 * c1[1], γ1 = c1[0] * c1[0] + c1[1] * c1[1] - c1[2] * c1[2],
α2 = -2 * c2[0], β2 = -2 * c2[1], γ2 = c2[0] * c2[0] + c2[1] * c2[1] - c2[2] * c2[2],
A = α2 - α1, B = β2 - β1, C = γ2 - γ1,
sqA = A * A, sqB = B * B;
let [l1, l2] = [[0, 0], [0, 0]];
if (sqA > sqB) {
l1[0] = -C / A; l1[1] = 0;
l2[0] = (-B * height - C) / A; l2[1] = height;
} else {
l1[0] = 0; l1[1] = -C / B;
l2[0] = width; l2[1] = (-A * width - C) / B;
}
const result = { l1, l2 }
return result
}
Insert cell
d3 = require('d3@v5')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more