Parametrization of Curve

Hi there!

I have a curve and a point of that curve at parameter t. I want two other points that have the same distance from that point in either direction of the curve.

However, I learned that parameter t is not equally distributed along the curve (Rhino - 3 Parametric Curves and Surfaces). That means, that the point at t-i of the curve has not the same distance as t+i to the point at t.

So, how I find two points that have the same distance in either direction to point at t on a curve?

I’m programming in C#, but answers using Grasshopper components are also helpful. Thanks for any help!

Assuming that “same distance” means what the confirmation part does (or you mean the pt.DistanceTo(otherPt) thing?)

if(crv == null || !crv.IsValid) return;
    if(d < tol) d = tol;

    double CL = Math.Round(crv.GetLength(), 3);
    Print("Length: {0}", CL);

    double DL = Math.Round(crv.Domain.Length, 3);
    Print("DomLength: {0}", DL);

    Print("P0 Length: {0}", Math.Round(CL * t, 3));

    Point3d p0 = crv.PointAtLength(CL * t);
    pointAtT = p0;

    Point3d p1 = crv.PointAtLength(CL * t - d);
    point1AtD = p1;

    Point3d p2 = crv.PointAtLength(CL * t + d);
    point2AtD = p2;

    // ----------------------------------------------------confirmation

    double t0; crv.ClosestPoint(p0, out t0);
    double t1; crv.ClosestPoint(p1, out t1);
    double t2; crv.ClosestPoint(p2, out t2);

    try{Print("L1: {0}", Math.Round(crv.Trim(t1, t0).GetLength(), 3));}
    catch{ Print("invalid t1");}

    try{Print("L2: {0}", Math.Round(crv.Trim(t0, t2).GetLength(), 3));}
    catch{ Print("invalid t2");}

As a small challenge: check d in relation to crv Length and t … and act accordingly (d should be >= tol).

1 Like

Thank you for your response!

.PointAtLength seems to be the way to go. However, there is still one problem… I calculate t by:

crv.ClosestPoint(myPointOnCurve, out double t);

where the parameter t is not normalized (unfortunately). That means

Point3d p1 = crv.PointAtLength(CL * t - d);

won’t return the correct point on curve. Do you understand the issue? What would you suggest?

Thanks again for your help!

Edit: I tried to normalize t by

            Point3d pS = crv.PointAtStart;
            crv.ClosestPoint(pS, out double tS);
            Point3d pE = crv.PointAtEnd;
            crv.ClosestPoint(pE, out double tE);
            double normalizedT = (t - tS) / (tE - tS);

and by

            double normalizedT = (t - crv.Domain.Min) / crv.Domain.Length;

which both did not yield the correct result. I think the reason is that t is not equivalently distributed.

I found a solution:

Point3d pS = crv.PointAtStart;                    
crv.ClosestPoint(pS, out double tS);
Curve trimmedCrv = crv.Trim(tS, t);
double lengthToMidPt = trimmedCrv.GetLength();
Point3d p1 = crv.PointAtLength(lengthToMidPt - d);

Since p1/t1, p0/t0 and p2/t2 yield Intervals used to Trim (in the confirmation part) the crv into segments that have the same (rounded) Length … well … it’s rather obvious my dear Watson.

Curve_PointsAtDistInRelationToPt_V1.gh (12.9 KB)

PS: As a challenge mastermind the approach for a closed Crv.