Grasshopper

algorithmic modeling for Rhino

I have an input of multiple end points from different curves. I use the Path mapper twice to re structure the list into couples of end points for each curve. Out of interest is there a way to remap just once and achieve the same result?

Views: 1514

Replies to This Discussion

{a}(i) -> {i % 2}
Thanks Trevor.

Another one for the books. I never thought to use modulo
nor I the backslash, it's definitely more legible in a pathmapper than 'floor(i/2)'.
Is there a similar shorthand for 'ceiling'?
Man, I stared at this thing for over 10 minutes and couldn't come up with anything. I stand in awe of your reductionist genius sir!

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hey Trevor

I understand how the Path Mapper works fine but, can you explain what the % (modulo) is doing as thats totally new to me, As guessing its not percentage in tis context... or is it?

Thanks Matt
David, that's quite a compliment coming from you. The first scripting course I took stressed the power of the mod pretty hard, I guess.

Matt, modulo returns the whole number remainder after the first term is divided by the second.
so for
i = 0,1,2,3..
i % 2 = 0,1,0,1..
i % 3 = 0,0,1,0,..
etc.

It's a great and simple way to make repeating value lists from a series or loop
would it not be i % 3 = 0,1,2,0,1,2...
yes, sorry, of course, typed to fast
If the curves don't have any kinks you can simply use an explode curve component.
yup, that would be simpler still.
I think that the OP wants one path for each curve, with only two items on each path, right? Using {a}(i) -> {i % 2} will create only 2 paths one containing all the start points and the other all the end points.

You'll have to use weave instead of merge and {floor(i/2)}. Or you can use a graft tree component before the end points component.

I just remembered this thread:
http://www.grasshopper3d.com/forum/topics/select-lists-by-index

Seems that mod works for that after all, I'm not sure why i mentioned it by didn't try it.
good point, you could also graft the start and end lists before merging (probably easiest though maybe not always an option) or pathmapper as {i % (item_count/2)}

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service