Grasshopper

algorithmic modeling for Rhino

The problem is as follows:

I have a list of 12 items and want a new list whose elements are sums of three of the elements of the original list. elements are vectors.

conseptual attached an image and code in Python

any help would be very useful!

thanks

Views: 1468

Attachments:

Replies to This Discussion

Hi Fernando,

you can use the PathMapper to group your long list of vectors into sublists of 3.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Attachments:

thanks david for your reply

I fail to see your raise. Anyway, my intention is to this purpose in the Python code. Ivastaria an example for how to adapt to my code. If you look at the attachment I am not far to do!

Attachments:

Ah, I don't do python support (I suck at it), but in C# it would be something like this:

List<Vector3d> vectors = ......;

List<Vector3d> result = new List<Vector3d>();

for (int i = 0; i < vectors.Count-2; i += 3)

{

  result.Add((vectors[i] + vectors[i+1] + vectors[i+2]) / 3.0);

}

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Hi again Fernando,

what David wrote would be:

# choose list access for "vectors", and type hint it as Vector3d
result = []
for i in range(0, len(vectors) - 2, 3):
   result.append((vectors[i]+vectors[i+1]+vectors[i+2]) / 3.0)

Thanks,

- Giulio
________________
giulio@mcneel.com

David, all this stuff with the sum of the list is to solve this problem ...

http://www.grasshopper3d.com/forum/topics/vector-forces

If that's what guys look!
I complicate the issue with the function "range ()" until I realized it works!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service