Grasshopper

algorithmic modeling for Rhino

That might not even be the right way to describe what I want, but can anyone help me generate a series of n numbers that follow a random cyclical wave pattern...

So sort of like a random sine wave but it must cycle round after n points so would appear continous if wrapped in a circle.

Views: 1730

Replies to This Discussion

Isn't it as simple as this?

Nice piece of code, by the way!

Yes, you can do it like that!

My old code did it like this...

but it doesn't wrap back around to the beginning.

Gives a slightly nicer mesh than the MeshBrep option although I'm sure you could tweak the settings a bit

Attachments:

Bodge applied for a complete mesh...

Attachments:

Yes its that simple, now that that you showed me how :) Thanks!

and for Martyn: checkmark Closed Loft in Loft options: that will close the loop. 

closed loft option closes the mesh if you use the loft but I'd done it a different way using some VB Script I wrote a while ago. It takes a list of points around each section curve and rearranges them into a list of points you can use to generate mesh faces so you end up with a triangular mesh that is nice and even.

You can probably still get a nice even mesh using the MeshBrep command if you tweak the mesh options and then do some weaverbird subdivisions and smoothing. The standard mesh settings gives you an eneven mesh like the image I posted.

Well, what you probably want is best thought of as N periods (or cycles), and then you can divide each period, or your total number of periods, into y points. Then, you can scale each point according to an amplitude  which can vary, say, so much per period (smoothests) or randomized per each point (very rough) or somewhere in between. As long as you stick with multiples of the periods, it should line up when you repeat the pattern. If you want to vary the wavelength, you can scale each period, which will give you a different length for each wave of the waveform. To get this to a known length, calculate the total number of periods and their length linearly), then scale the total to the length of curve that you want. easiest way to generate a reference baseline is a line from the start point to the end point.

I'm sorry to see this thread descend into trading VB/C# code solutions.  End of Grasshopper discussion as far as I'm concerned.  NOT INTERESTED in VB/C# when there are perfectly good answers using standard GH.

Second, I looked at David's reply and see an EXCELLENT response (as usual), making perfect sense from a vaguely worded question.  Unfortunately, it looks like his time was wasted in this case?

Finally, and this is off the subject of the thread title, I'm curious how to turn a lofted surface into a faceted polysurface?  No matter what 'Custom Mesh Settings' I use ('Min Edge' seems to be the only one that makes any difference?), the mesh surface never appears to be flat panels (facets) but always looks smoother and more curved than I expect.  What's up with that?

Your mesh looks nicely faceted and I can get the same result as a polysurface (brep) as follows:

How can I get the same result without your VB component?

I'm with you in preferring a GH solution but I don't think you should be so dismissive of script. Understanding scripting can help you become a better GH user. There is always a danger of quickly dismissing GH components and launching into a script but there's a time and a place for script.

Pure GH definitions are good because you don't need to understand script but some scripted solutions seem to run faster. I guess it depends on how good the script is! In my case it's probably quite basic but I'd scratched my head for weeks when I finally put my very basic VBScript skills to use and found it quite satisfying to do.

The original thread was about random cyclic / periodic functions and I got close to what I wanted with GH after taking on board David's advice and doing a bit of thinking for myself. There's probably a solution using the Expression component too.

You've followed the sidetrack from random functions to meshes and polysurfaces so give us a break if we want to look at some script, eh? :)

I tried to mesh the section curves using a few Series components to select the vertices of the section curve divisions and arrange them in a list of branches of 4 vertices that can be used to create a mesh face...

So, when you use DivideCurve on 100 section curves you get 100 branches of n points.

I tried to select {0;0} and {0;1} and {1;1} and {1;0} for the first mesh face

then {0;1} and {0;2} and {1;2} and {1;1}

then {0;2} and {0;3} and {1;3} and {1;2}

etc until {0;n-1} and {0;0} and {1;0} and {1;n-1}

That would give you vertices for quad mesh faces to fill the loop between the first and second section curves.

After that you need to do the same between the second and third section curves and so on until you do it for the last and first section curves to close the "loft"

You can do this by doing something along the lines of a Series of 0 to n-1 and plug that into the start parameter of a Series step 1 count 2 and then use that Series as the input to a List item

This isn't the whole solution, but you get the picture. It starts getting really complicated in terms of data structure to get the output of (n x 100) branches of 4 vertices (the right 4 vertices!) to plug into a Construct Mesh component but I'm sure it could be done (just not by me right now so I resorted to some script I'd done a while ago that does a similar thing only with triangles instead of quads)

Hopefully someone will do this in about 3 GH components and make me go "ahhhhh FFS!"

No, this isn't the place for VB/C# scripts, sorry.  There is a separate forum for that:

http://www.grasshopper3d.com/forum/categories/vb-c-and-python-codin...

I've been a programmer for more than forty years and could get into it (and have been tempted at times by frustration with GH's lack of recursion and other basic programming features) but the beauty of GH is being able to do stuff by just connecting components.

For most people, VB/C script solutions teach NOTHING, even if they do solve a problem.

P.S.  Another major reason I don't like the idea of using someone else's C script is the risk of Trojan/virus code...

Yeah there's another forum for code and that's for questions about code, but I don't see anything wrong with offering code solutions to problems posted here in General Discussion. We will have to agree to differ.

If someone really wanted to infect your PC I'm sure they could do it in a GH def that appeared to not have any code. I don't think there's any more risk to downloading a def that someone states has code rather than a def that doesn't appear to have any code in it.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service