Point at a certain length along the curve

rhino5

#1

Hello! :slight_smile:
How can I get a point at a certain length along the curve?
I am using “Rhino 5 for Windows C++ SDK”.
I’ve just realized that I do it wrong (Set domain [0.0; length] and just get point by domain).
The only solution I found for now is to use “RhinoDivideCurve()” and get first point as a result.
Are there easier way?
Thanks in advance!


(Dale Fugier) #2

Here is something I quickly typed up:

ON_3dPoint GetArcLengthPointOnCurve( 
  const ON_Curve& curve, 
  double length
  )
{
  ON_3dPoint rc = ON_UNSET_POINT;
  double crv_length = 0.0;
  if (curve.GetLength(&crv_length) && crv_length >= length)
  {
    double s;
    if (length == 0.0)
      s = 0.0;
    else if (length == crv_length)
      s = 1.0;
    else
      s = length / crv_length;
    double t = 0.0;
    if (curve.GetNormalizedArcLengthPoint(s, &t))
      rc = curve.PointAt(t);
  }
  return rc;
}

Does this help?

– Dale


#3

It worked!
Thanks a lot!