Circles Fractal in C#

Hi, I’m exploring recursions in C#, so I decided to start with simple circle scaling as shown in the ref image. But wasn’t able to code it properly, Any help with this?

Please find attached the ref image and c# code.



Circles (5.0 KB)

private void RunScript(Circle circle, int iters, ref object A)
  var list = new List<Circle>(){ circle };
  Subcircles(circle, iters, ref list);
  A = list; 

public void Subcircles(Circle c, int i, ref List<Circle> list)
  double r = c.Radius / 2.0;

  Plane p0 = c.Plane;
  p0.Translate(p0.XAxis * -r);
  Circle c0 = new Circle(p0, r);

  Plane p1 = c.Plane;
  p1.Translate(p1.XAxis * r);
  Circle c1 = new Circle(p1, r); 

  if(i > 0){
    Subcircles(c0, i - 1, ref list);
    Subcircles(c1, i - 1, ref list);

Circles (4.5 KB)

Thanks a lot!