0

I am trying to use a variation of this code from https://stackoverflow.com/a/53426084

let number = 12; // how many number to be placed
let size = 260; // size of circle i.e. w = h = 260
let cx= size/2; // center of x(in a circle)
let cy = size/2; // center of y(in a circle)
let r = size/2; // radius of a circle
let nodes = [];

for(let i=1; i<=number; i++) {
  let node = {}
  let ang = i*(Math.PI/(number/2));
  let left = cx + (r*Math.cos(ang));
  let top = cy + (r*Math.sin(ang));
  node.x = left;
  node.y = top;
  nodes.push(node)
}

But let's say I already have the position of n num of nodes. Would I be able to make this a bit more dynamic to be able to support that?

Basically I will have a node have a circle of nodes around it. And then those circles will have nodes around them but I want that 'parent(s)' node to be part of the distributed points.

Baecho
  • 43
  • 4
  • 2
    You can calculate center and radius of circle having coordinates of three points at the circumference. Look for these words or `Circumscribed Circle` – MBo May 17 '23 at 03:39
  • Can you give a few examples of input and what you expect as output for them? – trincot May 17 '23 at 14:38

0 Answers0