Grasshopper

algorithmic modeling for Rhino

changing sign (+/-) in lists and/or angle between 2 vectors

Hi all,

I am pretty new to both Rhino and GH. (started 3 days ago) Everything was breezy until I got stuck with this problem.  

1. I have set of numbers in my list. (e.g. {a1, a2, a3, a4, a5, a6, ..., a1200)}) Is there any way I can make this list into {a1, a2, a3, a4, -a5, -a6, -a7, -a8, a9, a10, a11, a12, -a13, ..... , a1200} ? ( 4 positive signs then 4 negative signs and so on) - alternating every nth in general. 

or 

2. Is there any way (workaround) to get negative angle value from 2 vectors? I know 'ANGLE (of 2 vectors)' component by itself doesn't work and I know why too. I have feeling that the reflex angle output might be useful but again, matter of list manipulation. 

Any help would be greatly appreciated. Thanks in advance.

Hyo

Views: 1529

Replies to This Discussion

I dont have GH at hand, but by the mean time while no replies appear, you can try this,

If it is just a list of items, i assume it is a floating number, you can split the list according to a pattern : TTTTFFFF, so it splits the list into two. One of the output you do a mathmetical operation which turns it to negative (eg: use a function 0-x or use a subtract operator) then weave the two list back using a similar pattern, TTTTFFFF.

I'm not sure if this works or now, otherwise you can try using tree structure, which is more coplicated for me.

cheers
Victor
Thanks a lot for the input, Victor.

I looked at the 'list' and 'tree' part closely again following your suggestion. I had no knowledge on culling and weaving 'patterns'.

After figuring out the logic with a hard coded true/false list (picture #1), I created the true/false stream that is controlled by parameters in my drawings. (picture #2) In my project, the 'int' stream and 'repetition' information can be feed parametrically.

I sill have feeling that my solution is too complicated. Please help me improve (simplify) this. Anyone?

Hyo
Attachments:
Try this.
"Floor (x/y)" gives you a list of integers repeated (in this case) 4 times: 0,0,0,0,1,1,1,1,2,2,2,2...
"_ mod 2" turns that list into 0 and 1: 0,0,0,0,1,1,1,1,0,0,0,0...
"_ -.5) *2" changes that list to 1 and -1: 1,1,1,1,-1,-1,-1,-1,1,1,1,1...

Do definitely look more closely at lists, treas, cull, weave, etc. though. They are the solutions to 65% of GH problems.
Attachments:
Wow, this is really nice!

so the 'floor' being... that of 'floor and ceiling' function? Very creative. I am definitely going to use this.

Thanks a lot!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service