Hello!
I am trying to array circles with 3 different radii randomly along a curve but I haven’t been having any luck.
I started by trying with the divide distance as that would allow me to set a base diameter for each circle but the divide distance applies the different distances simultaniously, so it ends up dividing the curve multiple times.
Here is a picture of what I am trying to achieve (sorry for the bad drawing)
The circles should be tangent to eachother.
I have tried that solution but it doesn’t seem to be working, as I am not trying to move the circles manually. I want to divide a line with the distances of the diameter and then divide those diametres into the circle radii.
I have found another workaround, that does not guarantee the tangency of the circles but seem close enough for me at least:
private void RunScript(Curve curve, List<double> radiuses, ref object A)
{
//Calculate the center of circles with specified radius on a curve
List<Point3d> lst_points = new List<Point3d>();
Point3d pointOnCurve = CurveCircleIntersection(curve, curve.PointAtStart, radiuses[0]);
lst_points.Add(pointOnCurve);
for (int i = 1; i < radiuses.Count; i++)
{
double radius = (radiuses[i - 1] + radiuses[i] );
Point3d pointOnCurveNew = CurveCircleIntersection(curve, pointOnCurve, radius);
if (pointOnCurveNew != Point3d.Unset)
{
pointOnCurve = pointOnCurveNew;
lst_points.Add(pointOnCurve);
}
else
{
break;
}
}
A = lst_points;
}
// <Custom additional code>
/// <summary>
/// Calculate the point on a curve that is at a certain radius from a point
/// this point must be after the previous point
/// </summary>
/// <param name="curve">The curve</param>
/// <param name="point">The point on the curve</param>
/// <param name="radius">The radius at which the new pointt must be from previous point</param>
/// <returns>Next point, Point3d.Unset if no point found</returns>
Point3d CurveCircleIntersection(Curve curve, Point3d point, double radius)
{
double tolerance = 0.0001;
double overlapTolerance = 0.0001;
Point3d output = Point3d.Unset;
double t = double.NaN;
curve.ClosestPoint(point, out t);
if (t != double.NaN)
{
Circle circle = new Circle(Plane.WorldXY, point, radius);
CurveIntersections ci = Rhino.Geometry.Intersect.Intersection.CurveCurve(curve, new ArcCurve(circle), tolerance, overlapTolerance);
double tMinOK = double.NaN;
foreach (IntersectionEvent ie in ci)
{
if (ie.ParameterA > t)
{
//First parameter that is OK
if (Double.IsNaN(tMinOK))
{
tMinOK = ie.ParameterA;
output = ie.PointA;
}
else
{
//If a parameter is nearer
if (ie.ParameterA < tMinOK)
{
tMinOK = ie.ParameterA;
output = ie.PointA;
}
}
}
}
}
return output;
}
Look at plugins for Jewels, Peacock, …
See these threads
The script @laurent_delrieu posted above does work without intersections - the circle centers lie on the curve, not the points of contact between the circles.
Using a mesh with an image to calculate a radius with a brightness, so all circles are tangents and here are on a spiral
SCARLETT JOHANSSON BY LEETA HARDING
I said sorry and clarified what I wanted.
What more do you want then? Canyou be clearer on how should I be clearer in my question?
I havent accepted the solution yet because I haven’t had the chance to test the solutions out.
Once I find a suiting solution I will mark this as solved.
If you don’t want to help you can refrain from replying. I didn’t ask you personally for a solution, you don’t need to act offended when someone doesn’t think your solution works for their needs.