Grasshopper

algorithmic modeling for Rhino

i know its a simple thing. but for the life of me i cant write the right code to return the vector length (as in magnitude NOT ARRAY LENGTH!). Every attempt of mine is returning the array length or 0.0 for all indices... bascially whats the syntax i should be using

--failure clusterfrak number 1--

//note im doing this in grasshopper. "x" is one "Point3d" point, "y" is a list of Point3d's

   

    Vector3d stan = new Vector3d(x);
    Vector3d[] cartman = new Vector3d[y.Count];
    Vector3d[] kenny = new Vector3d[y.Count];

    //double[] kyle = new double[y.Count];

    for(int i = 0; i < y.Count; i++){
      cartman[i] = new Vector3d(y[i]);

      kenny[i] = Vector3d.Subtract(cartman[i], stan);
    }

    A = kenny.Length;

// all this does is return the array length

--screw up num 2

    Vector3d stan = new Vector3d(x);
    Vector3d[] cartman = new Vector3d[y.Count];
    Vector3d[] kenny = new Vector3d[y.Count];

    double[] kyle = new double[y.Count];

    for(int i = 0; i < y.Count; i++){
      cartman[i] = new Vector3d(y[i]);

      kenny[i] = Vector3d.Subtract(cartman[i], stan);
      kyle = kenny.GetLength;
    }

//this one just fails to run and throws up something about converting to a non delegate //type...

any ideas?

Views: 2752

Replies to This Discussion

nevermind. i figured it out. all i needed to do was run

kyle[i]  = kenny[i].length;

and then return kyle....

now if i could just figure out how to Sort this damn thing from lowest value to highest id be all set.

nevermind again...

Array.Sort(kyle);

Hi Mario,

I never use Arrays unless I'm working on ultra-performance-critical code. List<T> is soooo much easier to use and RhinoList<T> is better still.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Why is RhinoList better?  What is the difference?

I wrote it :)       and it has a Last property.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I should say that since this post ive started using RhinoList religiously!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service