I have been trying everything to get this right, but I haven’t found a satisfying solution… what I am trying to do is create curves that connect the inner and outer rails where the (red) section curves go from straight to feathering out in order to cover the outer corners where the outer curve is considerably larger than on the inside. The difficulty is that the lines are supposed to be closer together towards the corners and get further apart in the straight segments but always staying inside a specified domain of min. and max. spacing. If that’s not possible then I’d be happy with just interpolating the section curves equally between straight and feathering out as indicated by the thicker lines.
I hope someone has an idea because simple sweeping or dividing both curves and then connecting the points doesn’t work for this specific problem… Context: The space between the curves has to be covered with circular rods that have a loose spacing with gaps in between them where the two rail curves are parallel and get as close as possible in the corners (which means that the minimum spacing would be 2xRadius in order to prevent overlapping).
When you are happy with that. Extract the start and end points and make 2 polylines.
Then initialize your section curve, first line is beginning at start of 2 polylines.
Then search next point on each curve, the common parameter is the maximum of parameter for curve 1 and parameter for curve 2. It works here because for polyline parameter is linked to the control points. t=0 means first point, t=6 means 7th point … and if a line begin on point number N on a polyline it must be on point number N on the other polyline.
private void RunScript(Polyline pl1, Polyline pl2, double minDistance, ref object A)
{
PolylineCurve plc1 = new PolylineCurve(pl1);
PolylineCurve plc2 = new PolylineCurve(pl2);
List<Line> lines = new List<Line>();
lines.Add(new Line(pl1.First, pl2.First));
double distanceOn1 = 0;
double distanceOn2 = 0;
for (int i = 0; i < 1000; i++)
{
double t1, t2;
//We search point at a certain distance on each polyline
if (plc1.LengthParameter(distanceOn1 + minDistance, out t1) && plc2.LengthParameter(distanceOn2 + minDistance, out t2))
{
double t = Math.Max(t1, t2);
Point3d p1 = plc1.PointAt(t);
Point3d p2 = plc2.PointAt(t);
lines.Add(new Line(p1, p2));
distanceOn1 = plc1.GetLength(new Interval(0, t));
distanceOn2 = plc2.GetLength(new Interval(0, t));
}
else
{
break;
}
}
A = lines;
}
I didn’t find a simple solution, perhaps there is a geometric one. Also this solution is not perfect as tubes are not parallel distance between point is not enough to ensure no collision.
Thank you! This worked with some minor changes, like filleting the edges in order to get the points closer together and then adjusting the min.Distance in order to accomodate the fact that the point are now technically further out from the curve, but that’s fine. Here is the code:
I guess it’s not really possible to increase the point count towards the corners so that the points get as close as possible to min.Distance while getting closer to max.Distance in the parallel sections?