Grasshopper

algorithmic modeling for Rhino

How to divide a circle in segments of 2 different lengths

What im wondering is;
Let's say that i have a circle, and i want to divide it in segments of even numbers.
Ex: A circle of 8 sections

Now, what i want to do, is to part the circle, so that the sections have 2 different lengths.
Ex: 0, 2, 4 and 6 gets one length, while section 1, 3, 5 and 7 gets another

Anyone here that has a good solution for this?


Sincerely,

Brage

Views: 2292

Replies to This Discussion

Hello Brage,

this could be a way

cheers

alex

Attachments:

Thanks Alex!
This works really great!
But since I'm still a bit new to GH and how it works, would you mind explaining how the GH-file works from the beginning until the "Shatter" component? (The part with the circle isn't important though)
Especially the the "X variable" and the box with the "if" rule puzzles me a bit :)

Great thanks,

Brage

Hello Brage,

we have a circle with variable radius. then we have a slider, working with even numbers only driving the division of the circle. Since the curve is reparametrized, the t values are between 0-1, hence the range component has a 0-1 domain. So the division component finds t value for an even division of the curve, according to the division slider. Dispatch component dispatches the even (for now) t values coming out the range component, with a true false pattern. The first list of values is subtracted a value coming of the other slider, in order to output t values for the smaller segments. If you subtract 0, then you have even segments. These t values are weaved, with a 0 1 pattern (same as dispatch), with the unchanged t values. The slider for the small segments is passed through the evaluation component. The expression makes sure that if the value of the slider is larger than the t(y input from the division output) value needed for even division, then use the y value. If it smaller, then use the sliders value. That way you will not provide larger subtraction than needed, which would result in evaluation t's running around the circle.

hope that helps.

best

alex

Thanks again Alex! :)
Makes a bit more sense to me now ^^

cheers,

Brage

I like you way of solving it Alex, but had seen on my travels a dashed line component and also wanted to see if it could be done with real length's so created this.

Matt

Attachments:

Really nice Matt! thanks for sharing. I tried dashed line but got lazy finding out the expression needed to generate the points

actually, real lengths could be used in the previously posted definition, if one curve length component is added and then feeding the output to domain input in range, a input in division, after disabling reparameterize option in C input of the shatter component.

best

alex

Good to know, I started by making your code.. missed the link and followed the picture (doh) then trying to hack it, before I worked out how I could do it as posted.

Cheers

Matt

your solution shows how powerful expressions are, sometimes bypassing many components.!

This puzzle caught my attention so I figured I'd give it a go :)

I definitely could have added a better thought out dependency, but it seems to function even though it is a much simpler approach. Nevertheless, you both have inspired me to use more expressions.  

 

Attachments:

An another approach could be to construct arcs from consecutive domains...

There are some clever, problem-specific solutions here, but I can't help noticing that this question is basically the same as the one in the 'Maths + Divide Curve' thread.

So I plugged in this sequence: 2,4,2,4,2,4,2,4

And low and behold, discovered an off-by-one error in the previous code!  An unnecessary 'Shift' that resulted in one fewer segments than expected.  Don't know how I missed this...

There is no extra code here to highlight and dimension the segments.  Using a sequence of numbers to drive the split is quite powerful, allowing many different combinations of segment lengths.

Attachments:

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