Create middle curve between two curves


I have an imported cross section from igs or step file. I want to select two curves from the cross section and create a middle curve between two curves. The two selected curves can be parallel or may not be parallel. Please refer to the attached image with sample curves. Please share if any algorithm is available, which can take the two user selected curves as input and gives the middle curve as output.

Roman Lygin's picture

Hi Sekhar,

To the best of my knowledge there is no direct algorithm to construct such a curve (it does not exclude that it might exist though).

The way you could do this is to define your own subclass of either Geom_Curve or Adaptor3d_Curve and approximate with the help of B-Spline using GeomConvert_ApproxCurve.

When defining your subclass you will need to describe how your target curve is evaluated at every parameter t. Depending on desired target continuity you will need to define methods D0(), D1(), D2(), D3(): when requesting C0-continuity only D0() will be invoked, for C2 - D0()-to-D2().

Let's consider the simplest case. Let your input curves be c1(t) and c2(t), both defined on equal range [a,b] and every point along them corresponds to the same parameter t. In this case your target curve is simply cm(t) = 0.5 (c1(t) + c(t)). So your methods would be as simple as follows:

void MyMidCurve::D0 (const Standard_Real U, gp_Pnt& P) const

   P = 0.5 * (myC1(U).XYZ() + myC2(U).XYZ());


//same for D1 - D3

If you need a more complex case, for example a parametrization by length, i.e. point with parameter t=0.25 would correspond to medium points of c1 and c2 evaluated at their 25% lengths respectively then your target curve will be represented as this:

cm(t) = 0.5 (c1(a(t)) + c2(b(t)), where

a(t) and b(t) are functions mapping your parameter t to respective domains of original curves. If you do not have exact law you could approximate/interpolate them. For instance, for length parametrization you could use CPnts_AbscissaPoint to compute points at certain length.

Then you would define D-methods using the formulas:

cm(t) = 0.5 (c1(a(t)) + c2(b(t))

cm'(t) = 0.5 (c1'a * a't + c2'b * b't), where c1' a is first derivative of myC1(a(t)) and a't is D1 at parameter t.

Might sound complicated but with some insistence you can do this ;-). For more details you could refer to this post -

Good luck!


Guido van Hilst not specified's picture

Hi Sekhar,

I have made a small script to get a middle wire between 2 other wires. (no need to be paralell, or equal edges)

See:  MiddleWire

​Maybe it can give you some ideas?

Best regards, Guido