Help : How can I draw a circle along a line?

How do you try to create a circle along a line and a minimum number of circles that contain all the points around the line?

I don’t get the problem: you can draw a single circle on a curve that contains all points.

Circle size is limited.

image

if you are looking for the minumum number of circle, with center on a curve, that envelop all the points given I think you should go for an optimization algorithm, like Refinery, or the older Optimo package.
You will have only 1 objective: minimize the number of circles.

Yes, but I am beginner. So I cannot solve this. But I try to solve it through optimization algorithm. Thank you…

You can find a single minimal circle lying on the line that contains all the points fairly easily:

If you want to have multiple circles, look into a way of clustering the points together and then using the same procedure from above on each cluster.

1 Like

Thank You. I will try It…

The principle is similar to that suggested above by @Dimitar_Venkov


circles.dyn (7.8 KB)

def dis1 (p:var[]..[],r:var[]..[])
{
	a = Math.Ceiling(List.MaximumItem(p.DistanceTo(r)));
	b = r.ClosestPointTo(Point.ByCoordinates(Math.Average(p.X),Math.Average(p.Y),Math.Average(p.Z)));
	c = p.DistanceTo(b);
	d = List.FilterByBoolMask(p,c <= a);
	e = [b,d["out"]];
	return e;
};

def dis2(p:var[]..[],r:var[]..[])
{
	c = [Imperative]
	{
		a = dis1(p,r);
		b = a[0];
		d = a[1];
		e = 1;
		while (List.Count(d)>0)
		{
			f = dis1(d,r);
			b[e] = f[0];
			d = f[1];
			e = e + 1;
		}
		return List.Flatten(b,-1);
	}
	g = Math.Ceiling(List.MaximumItem(p.DistanceTo(r)));
	return Circle.ByCenterPointRadius(c,g);
};


//Points
a = List.Flatten([(-4..-1..#5),(4..1..#3)],-1);
pts = List.TakeItems(List.Shuffle(List.Flatten(Point.ByCoordinates(a<1>,a<2>),-1)),n);

//Rectangle
rct = Rectangle.ByWidthLength(1,3);

//Circles
cir = dis2(pts,rct);
[pts,rct,cir];

Warning: Multiple definitions for ‘Line’ are found as Autodesk.DesignScript.Geometry.Line, Geometry.Line
Multiple definitions for ‘Line’ are found as Autodesk.DesignScript.Geometry.Line, Geometry.Line
Multiple definitions for ‘Line’ are found as Autodesk.DesignScript.Geometry.Line, Geometry.Line

you have more “Line” defined in your Dynamo: try to write the full name, like Autodesk.DesignScript.Geometry.Line instead of simple Line.
It should help you with an autocompletition while trying to set it up.