Curve with 3 points constraint


I need to create a curve degree 3 with at least 6 control points.

To explain better I need to create the situation done in the SolidWorks Sketch I attached.

I know the position of start and end points (P0 and P5).

The highest point of the curve must pass through the point P and I know the position.

The variable inputs are:

  • P1 x,y
  • P2 x
  • P4 x,y

I need to define the correct values for P2 y and P3 x,y in order to keep the highest point of the curve on the point P.

SolidWorks can do this automatically.

I assume the best solution is P2 y = P3 y.

Is it possible to achieve a curve starting from this construction in Rhino or Grasshopper?



Why a minimum of 6 control points?

The curve will not be unique.

Because I need a minimum of control points to achieve the shape.

I could need more than 6 control points.

Your constraints can be satisfied with 5 control points, probably with 4. If more control points are needed for subsequent modifications use InsertKnot to add knots and control points. InsertKnot does not change the shape of the curve.

I need to move the control points to achieve the shape and the curve must always pass throught the point P.

When I create a curve with the command “control point curve” I can’t know where the curve will pass.

If I move P1 (from the example) the top of the curve will change.

How can I be sure that the highest point of the curve will always pass through the point P?

Use two curves rather than one. Create horizontal helper lines on either side of the middle point, and have next to end control point for each curve on the helper lines. That insures middle point will be locally the highest point, and the curves will have tangency continuity. If you need curvature continuity use Match after confirming the control points are on the helper lines.

Hi @patrick_n,

Can you post your curve here?

– Dale

Your sketch should work just fine if you follow David Cockey’s advice and move your P2 and P3 to a horizontal line that passes through your point P. If the general shape of the curve you want to end up with is like you show then you should be able to get exactly what you want by moving P2 and P3 only along the horizontal line and P1 and P4 anywhere you like. It will take some iterative playing with the points. David’s suggestion of treating the two sides as separate curves with one end of each at point P will ensure that the finished curve will go through P and will make it easier to adjust each side independently. Keeping P2 and P3 locked to the horizontal line is extremely key to having the two sides tangent at point P. Once you get each side adjusted to your liking you can join the curves into one if you wish. (33.2 KB)

Thanks @Mahdiyar that’s what I need!

That was the simplest case.

What if P2 y and P3 y are different?

Is it complex to adjust the script to manage the curve with 6, 7 or 8 control points?

sorry for the late reply, Here is a cleaner and faster version:

private void RunScript(List<Point3d> pts, Point3d p, ref object A)
    Plane perpFrame;
    Plane horiFrame;
    double tol = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
    var baseLine = new Line(pts[0], pts[5]).ToNurbsCurve();
    baseLine.PerpendicularFrameAt(0.5, out perpFrame);
    var perpLine = new Line(perpFrame.Origin, p);
    baseLine.FrameAt(0.5, out horiFrame);
    var tempPt = pts[2];
    pts[3] = tempPt;
    var c = NurbsCurve.Create(false, 5, pts);
    for (var i = 0; i < 300; i++)
      Box bb;
      c.GetBoundingBox(horiFrame, out bb);
      var edge = new Rectangle3d(bb.Plane, bb.X, bb.Y).ToPolyline().SegmentAt(0);
      var tp = edge.ClosestPoint(p, true);
      var v = new Vector3d(p - tp);
      pts[2] += v;
      pts[3] += v;
      tp = Intersection.CurveLine(c, edge, tol, tol)[0].PointA;
      var tpPerpToPerpLine = perpLine.ClosestPoint(tp, true);
      pts[3] += new Vector3d(tpPerpToPerpLine - tp);
      c = NurbsCurve.Create(false, 5, pts);
      if (p.DistanceTo(tp) < tol) break;
    A = c;
  } (26.6 KB)


And here is a simple Rhino plugin compiled for Rhino 6.

PatrickCurve.rhp (43.5 KB)
Source: (100.6 KB)

Thanks @Mahdiyar I appreciated your help!

Now the Y value can be different and it works very well.

I was wondering if it is possible to adjust the script to manage the curve with 6, 7 or 8 control points?

Sometimes I need more points to achieve the reference shape with tolerance.

I’m not sure if I fully understand where you want to add to these points and what constrains you to want to have.

1 Like

The constraints are the same: start, end, p point

with more control points