Grasshopper

algorithmic modeling for Rhino

Divide a Curve into Decreasing Increment Length

Hi

I'm trying to divide the length of a parametric curve that is constructed with control points into decreasing increments as per the attached sketch. I can easily divide the curve into equal length segments but am having trouble reducing the size of each increment.

 

Any help would be appreciated

 

Cheers

 

Bob

Views: 4246

Attachments:

Replies to This Discussion

Hi BoB,

 

if you are familiar with script components you can try something like this (assuming that you want linear increments)

 

  private void RunScript(Curve x, double y, ref object A)
  {

    tList.Clear();
    double t = x.Domain.Min;
    double increment = 0;

    tList.Add(t);

    while (t <= x.Domain.Max)
    {
      double s = t + increment;
      tList.Add(s);
      increment += y;
      t = s;
    }

    Curve[] curveArray = x.Split(tList);

    if (t > x.Domain.Max)
    {
      A = curveArray.Except(new Curve[]{curveArray.Last()});
    }
    else
    {
      A = curveArray;
    }

  }

  // <Custom additional code>
  List<double> tList = new List<double>();
  // </Custom additional code>

 

But be careful - don't enter y values very close to zero.

hey tzin tzon,

is there a new version up to date of that code?  

Here is two ways.

Attachments:

Thanks was great help!!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service