Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5749

Double convertTo.int?(Help)

$
0
0

I want Covert(double to int )… For use as index(Because the Random number produced from Double)
how?


covert.int.gh (9.4 KB)
  private void RunScript(int seed, double lenght, double v, Interval domain, ref object A, ref object B)
  {
    Vector3d pt = new Vector3d();
    var rnd = new Random(seed);
    var list = new List<double>();
    List < Vector3d > vx = new List  <Vector3d>{new Vector3d(v, 0, 0),new Vector3d(-v, 0, 0),new Vector3d(0, v, 0),new Vector3d(0, -v, 0),new Vector3d(0, 0, v),new Vector3d(0, 0, -v)};

    double index;

    for(var i = 0; i < 6; i++)
    {
      list.Add(domain.ParameterAt(rnd.NextDouble()));
    }

    index = Math.Round(list[0], 0);
    int indexN = Convert.ToInt(index);

    pt = vx[indexN];
    A = pt;
    B = index; 

4 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 5749

Trending Articles