Grasshopper

algorithmic modeling for Rhino

divide segment in random sub-segments with min and max lenghts

Hi all!

Does anyone know how i could divide a segment in a specified number of sub-segments, so that they do have random  lenghts but also have a min and max possible length?

thanks a lot!

Views: 5102

Replies to This Discussion

Haven't tested this, but I'd try to make a random list of number in the min-max range. Then use the Mass Addition component to add them all together and then use the Eval Length component with the Partial Result output. This will give you parameters that you can use the Shatter the curve.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
I thought of this, but doesn't really work.
Let's say You stop adding segments once the total length of the segment chain is past the lenght of the initial curve. You now want to make the result "chain" the same lenght as the inital curve.
You can either:
A) cut the surplus of the last segment, but it may result in a segment that might be shorter then the min acceptable value
B) scale the whole chain to the lenght of the inital curve, but if you had in the unscaled chain a segment that is at the minimum value, it will drop below this once you scale it down.

Weird problem, i thought of different stuff, but none actually does the job correctly.
You're right, the last segment is a problem.

What if you generate a list of increasing segments, whose total length is well defined, then jitter them?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
i don't really get how this helps...
isn't it the same problem, that the sum of the segments (which have random lenghts within a domain) is not exacly the same as the length of the curve that i want to split?
Well, they wouldn't be random in this case, they'd be a sequence. You could generate a sequence like this with a GraphMapper for example. You just have to be careful that the shortest and longest segments are within your range.

{1, 1.2, 1.45, 1.6, 1.8, 2.1, 2.3, 2.6, 3.0, 3.6, 4.3, 5.5}

then jitter them to introduce some of that sweet randomness.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
interesting, but if i put the values through graph mapper, unless the graph is a diagonal, the sum of the output values won't be the same as the sum of the input values
I meant:

1) create a line segment whose length matches the total length of the intervals you need.
2) divide this line segment into N sections using a [Evaluate Length] component and a range of numbers from 0 to 1
3) Feed the numbers through a GraphMapper, so the line division becomes irregular.
4) Extract each individual interval from the divided line, there's multiple ways of doing that, shatter for example, or using the division point coordinates directly.
5) Jitter the resulting intervals.


--
David Rutten
david@mcneel.com
Poprad, Slovakia
got it!
i wat thinking that i put the segment lenghts through the graph mapper, not the time of each split point.
thanks!

EDIT:

Although, i don't really know how i could input the min and max values for segment length..
Hi Andrei
Maybe this is what you need. I would do it simpler but I took all the expressions out of the components to make it clearer. It takes a curve and divides it in N random length segments. With the sliders that define the domain of the random component you can control the randomness of the divisions... The thing I don't understand is: Why don't I get segments of equal length if I specify a regular sequence in the t value of the scatter component? Shouldn't it do that?

Hi Frane,

no, it shouldn't. Or at least, there's no guarantee it will. Special curve types like Lines, Polyline and arcs might give you constant parameter speed, but NurbsCurves will be more 'dense' in some areas than others. When a curve is more dense, a certain parameter interval will be shorter.

Curve parameters are not good substitutes for physical distance.

Allow me to demonstrate with a curve type you're probably very familiar with; the Sine curve:


The Sine wave is defined by a single Parameter (just like nurbs curves), except we usually call it "x" rather than "t", but there's really no difference. For every x, this curve gives you a value of y. Nurbs curves give you 3 values for every t (x, y & z), so they're a bit harder to wrap your head around, but the principle behind them is the same.

Let's take a look at two intervals along the Sine wave {A; B}, both of which have the same parameter length. Yet the length of the actual sine wave portions differs greatly, almost by a factor of 2. This is the exact same effect.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Ah yes... that should of course be 2pi there in the corner. But in my defense; it's half past one in the morning.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hi David

I always thought that the t value was a parametric evaluation of the length of the curve. Then 0 would be the start, 1 the end, and .5 the half of the length along the curve...

I looked around and now I understand that "t" is a variable that will drive the formulas for the X,Y and Z coordinates of the curve. So for a circle of radius 1, on the XY plane, centered at (0,0,0), "t" goes from 0 to 2PI and the formulas are X=1*cos(t), Y=1*sin(t) and Z=0.
Is that it?
The U and V coordinates of a point in a surface are similar to the "t" value or are they related to the lengths of the two dimensions of the surface?

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