# Bridging parallel curves

#### Spacing based on maximum distance between consecutive beams

![](/files/-LfzmvWajWVwJqKsLdM9)

{% file src="/files/-LfznrNOarVM69CRhYEw" %}

```d
//Two Parallel Curves

a1 = Arc.ByCenterPointStartPointSweepAngle
(Point.ByCoordinates(0,10000),Point.Origin(),
90,Vector.ZAxis());
l1 = Line.ByStartPointDirectionLength
(a1.EndPoint,Vector.YAxis(),20000);
a2 = Arc.ByCenterPointStartPointSweepAngle
(Point.ByCoordinates(20000,30000),
l1.EndPoint,-90,Vector.ZAxis());
a3 = a1.Offset(5000);
l2 = l1.Offset(-5000);
a4 = a2.Offset(-5000);
p1 = PolyCurve.ByJoinedCurves([a1,l1,a2]);
p2 = PolyCurve.ByJoinedCurves([a3,l2,a4]);
n1 = NurbsCurve.ByPoints(p1.PointAtParameter(0..1..#100));
n2 = NurbsCurve.ByPoints(p2.PointAtParameter(0..1..#100));
```

```d
//Orthogonal Beams

max = 1000;
pt1 = br2(cr1,cr2,max);
pt2 = cr2.ClosestPointTo(pt1);
ln1 = Line.ByStartPointEndPoint(pt1,pt2);
[cr1,cr2,ln1];

//Points Spacing - Curve 1
d11 = List.DropItems(List.Sublists(pt1,0..1,1),-1);
d12 = Math.Round(List.FirstItem(d11<1>).DistanceTo(List.LastItem(d11<1>)));


//Points Spacing - Curve 2
d11 = List.DropItems(List.Sublists(pt2,0..1,1),-1);
d12 = Math.Round(List.FirstItem(d11<1>).DistanceTo(List.LastItem(d11<1>)));
```

```d
def br1(c1,c2,p1,s1)
{
	r1 = c1.ParameterAtPoint(p1);
	p2 = c2.ClosestPointTo(p1);
	r2 = c2.ParameterAtPoint(p2);
	p3 = c2.PointAtChordLength(s1,r2,true);
	p4 = c1.ClosestPointTo(p3);
	d1 = p1.DistanceTo(p4);
	p5 = d1<=s1?p4:c1.PointAtChordLength(s1,r1,true);
	pr = d1<=s1?c2.ParameterAtPoint(p5):c1.ParameterAtPoint(p5);
	return = [p5,pr];
};

def br2(c1,c2,s1)
{
	return = [Imperative]
	{
		n = 0;
		ct = 0;
		q = Math.Ceiling(c1.Length/s1);
		p1 = c1.StartPoint;
		p3 = [];
		while (ct < 1)
		{
			p3[n] = List.FirstItem(br1(c1,c2,p1,s1));
			ct = List.LastItem(br1(c1,c2,p1,s1));
			p1 = p3[n];
			n = n + 1;
		}
		return = p3;
	}
};
```

#### Spacing based on maximum area between consecutive beams

![](/files/-LfznDiQ6XynMmQf1GXz)

{% file src="/files/-LfznoGxKvwkWwJwBW-u" %}

```d
// Orthogonal Beams

//Max are in sqm
max = 10;
//Reduce beam spacing increment (mm) for greater accuracy
spc = 100;

pt1 = br2(cr1,cr2,spc);
pt2 = cr2.ClosestPointTo(pt1);
ln1 = Line.ByStartPointEndPoint(pt1,pt2);
ln2 = List.DropItems(List.Sublists(ln1,0..1,1),-1);
ar1 = Surface.ByLoft(ln2).Area/1000000;
ar2 = Math.Sum(List.TakeItems(ar1,1..List.Count(ar1)));
ln3 = List.GroupByKey(List.RestOfItems(ln1),Math.Ceiling(ar2/max))["groups"];

// Beams spaced with desired area between them
ln4 = List.AddItemToFront(List.FirstItem(ln1),List.LastItem(ln3<1>));
[cr1,cr2,ln4];

//Area between two beams
ar3 = Math.Round(Surface.ByLoft(List.DropItems(List.Sublists(ln4,0..1,1),-1)).Area/1000000);
```

```d
def br1(c1,c2,p1,s1)
{
	r1 = c1.ParameterAtPoint(p1);
	p2 = c2.ClosestPointTo(p1);
	r2 = c2.ParameterAtPoint(p2);
	p3 = c2.PointAtChordLength(s1,r2,true);
	p4 = c1.ClosestPointTo(p3);
	d1 = p1.DistanceTo(p4);
	p5 = d1<=s1?p4:c1.PointAtChordLength(s1,r1,true);
	pr = d1<=s1?c2.ParameterAtPoint(p5):c1.ParameterAtPoint(p5);
	return = [p5,pr];
};

def br2(c1,c2,s1)
{
	return = [Imperative]
	{
		n = 0;
		ct = 0;
		q = Math.Ceiling(c1.Length/s1);
		p1 = c1.StartPoint;
		p3 = [];
		while (ct < 1)
		{
			p3[n] = List.FirstItem(br1(c1,c2,p1,s1));
			ct = List.LastItem(br1(c1,c2,p1,s1));
			p1 = p3[n];
			n = n + 1;
		}
		return = List.Flatten([c1.StartPoint,p3],-1);
	}
};
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.testingwaters.in/geometry-1/orthogonal-spacing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
