Grasshopper

algorithmic modeling for Rhino

# Testing parallelity of lines in x,y,z space and

Hi I've been stuck on this problem for a few days.

Is there a simple way to group a set of lines according to their parallelity?

Thanks,

James

Views: 1030

### Replies to This Discussion

Hello James,

you have to use the sort along curve and sort points components. With the first you can group parallel vectors , and with the other one you can group parallel lines.

Haven't tested it in 3D.

Attachments:

Jesus,

Thank you very much for you quick reply - your solutions are very nice.  Can you think of a solution that would work for x,y,z space?

Thanks,

James

If you want it to work in 3D I suggest you used dot-product and/or cross-product operations.

Jesus, are lines only perpendicular if they are in same direction? wouldn't vectors that are reverse of each other also be perpendicular?

also the partition list doesnt work as its just roughly grouping the lines,

e.g. If there was 2x(0,10,0) and 8x(10,0,0) vectors, the partition list would just put 5 in each group irrespective of the perpendicularity. Sorry to be a buzz kill

I think i have a quick-fix for the first solution,

Nick the grouping isn't really an issue, it's just arbitrary for graphical purposes (if I understand correctly).  You can always create a set which finds all the distinct elements in a group and then do a member index search to find the respective index of each distinct element within the original set.

Don't worry for the "buzz kill", I also wanna learn new things!

Hello Nick,

I don't understand your question. Did you mean parallel as opposed to perpendicular? If so, that is why I did two versions, one for lines and another for vectors. Vectors are grouped if they point to the same direction; lines are group regardless of start-end direction.

Jesus and Nick,

What I've essentially got is a set of lines generated by proximity.  I can group them according to their vectors, i.e. direction simply by turning them into vectors, unitizing them and then making a set.

However, would be great if I could have set of lines grouped even if their vectors were in opposite directions.  Please see attached file:

Thanks for your help so far :)

Attachments:

James, here you go. There was alot of duplicate lines, so you may want to generate your structure differently.

Essentially i have sorted all the lines so that they attempt to point in the same direction. Then grouped them according to vector.

Attachments:

Very nice. It seems it works only if the lines are parallel. There is no grouping if they are not completely parallel.

Here is one that groups vectors according to which way they point at. Note however that they are groups are grafted (one group for every vector). Hence if you want to create a singular set (instead of as many sets as vectors), you'll have to work it out some more.

cool. team work. I will think on it.

• View All