function getSelfRefCoordinates(ctx, angle, radius, node) {
  let x = node.x;
  let y = node.y;

  if (typeof node.distanceToBorder === "function") {
    //calculating opposite and adjacent
    //distaneToBorder becomes Hypotenuse.
    //Formulas sin(a) = Opposite / Hypotenuse and cos(a) = Adjacent / Hypotenuse
    const toBorderDist = node.distanceToBorder(ctx, angle);
    const yFromNodeCenter = Math.sin(angle) * toBorderDist;
    const xFromNodeCenter = Math.cos(angle) * toBorderDist;
    //xFromNodeCenter is basically x and if xFromNodeCenter equals to the distance to border then it means
    //that y does not need calculation because it is equal node.height / 2 or node.y
    //same thing with yFromNodeCenter and if yFromNodeCenter equals to the distance to border then it means
    //that x is equal node.width / 2 or node.x
    if (xFromNodeCenter === toBorderDist) {
      x += toBorderDist;
      y = node.y;
    } else if (yFromNodeCenter === toBorderDist) {
      x = node.x;
      y -= toBorderDist;
    } else {
      x += xFromNodeCenter;
      y -= yFromNodeCenter;
    }
  } else if (node.shape.width > node.shape.height) {
    x = node.x + node.shape.width * 0.5;
    y = node.y - radius;
  } else {
    x = node.x + radius;
    y = node.y - node.shape.height * 0.5;
  }

  return { x, y };
}
Returns x, y of self reference circle based on provided angle
@param {object} ctx
@param {number} angle
@param {number} radius
@param {VisNode} node
@returns {object} x and y coordinates