Grasshopper - Sine Functions and Transformations

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys in this tutorial we are going to take another look at sign codes we're gonna start by looking at what we can do with sine curves in a let's go with one-dimensional direction so just just a simple amplitude value and then we're gonna take that exact same sort of principle and we're gonna apply it to a two dimensional level so that we can start to get some surface geometry out of this as opposed to just some curve so we're gonna be creating something like this alright so we're gonna start with the brand new definition and originally working in the top view for now so I'm gonna maximize that and I'm gonna start off by dropping down an expression so we're gonna so we're gonna set up our sine function as sine open parentheses and we're gonna use W times T W is going to be our sort of P period or frequency and then T is going to be our parameter along the curve alright let's get started we're also gonna change these inputs to W and T I prefer to use W and T just because of that's what we use in conventional physics well instead of W use that a symbol called Omega but it's looks similar enough to a W okay so we're gonna plug in we're gonna grab a range for starters and like we did in the other sine function tutorial we're going to drop down a domain and we want that domain to go from zero to two pi so it starts at zero so I'm just gonna drop down a slider here I'm gonna give it a maximum value of 1212 and then I'll also grab a PI component and so this pi component can basically basically just give you multiples of pi plug going to change my slider value to two and so now we're getting to PI and I'm gonna grab another slider and this is going to be how many steps I want and I'm going to set it to a maximum of 360 and I'll probably set the value to 360 then I'll plug that in so that's our T value and we also need a period value so I'm going to set this to actually ones Foley all right okay so now we're gonna get a construct point component which can be found in the vector tab right over here and our x value is gonna come out in this range and our Y value is coming out of here and so at the moment we have sits very our period or frequency to 0.25 so it's gonna give us a quarter of a full sine wave so I'm just gonna set that to 1 and there's my full sine wave also drop down and interpolate curve component so that we're not viewing if there's a series of points all right there we go No what else could we do with this what I'm getting what I'm gonna do is I am going to make a few copies of this Omega value well this w value and I'm just gonna graft it and then I'm gonna plug these in and you'll see what's gonna happen in the SiC basically we can plug these in and we can get multiple sine curves or multiple sets subsets of sine curves there we go so we have the full sine curve we have the half sine curve and we have the quarter sine curve through here now what else could we do with this we could maybe instead you know what let's let's try something let's do some sign sums or some sign multiplications so in order to do that if we're gonna be okay let's we have a parameter the U so we can see what we've got coming out of here I'm gonna plug this in and we've got three branches with 361 items each so I want to take only split these on a traverse this tree stretches that what I actually have is 361 trees each with three values the way I do that if you've seen my data star my data structures part two tutorial is a flip matrix component so we're going to flip that matrix and that's gonna basically swap all of these values with all of these values and so now we should have there we go 361 branches each with three items and now we'll drop down to different components one of them would be a mass addition and the other be a mess multiplication and these are really cool components because what they do is they just multiply or add every single value together in a list so this mass addition component adds everything in all these first three items or these three the next three or so and so forth the mass multiplication will multiply them all together so we should be getting just one value out of each of these and so what we can do with this is we can use this as our Y value instead of just the result of the sine function and so this is a really cool way to transform sine functions by adding together various results that you'll get and so we were we don't just want to plug that straight in there because at the moment we've got we've got 361 lists with one point each so if we plug that in it's it's not really gonna do anything that we want so what we need to do is we need to flatten this list and so now you might be wondering ah what is going on here in order to illustrate that I LUN flatten that and I'll flatten this Y and push and then I'll make a copy of this and I'm gonna take my value coming straight out of here and we'll unflattering it and so what's going on here for this what this is doing is it's taking all of these three values at any point it's adding them together and it's constructing a new point up here somewhere and so then over here it'll say I want to add these points as well as the corresponding point on this and that will result in a point somewhere along here on the line and so we can this is a really cool easy way to transform sine functions what we could also do is let's say we want to make all our values of sine positive it's a really simple thing to do we just take our sine function and we square it gonna turn these up and I'll plug in to my Y value and so now we get this and if we compare that to just an ordinary sine of WT so what it does is it squares every single value along here and returns the result and so anytime you square a negative number it's always going to result in a positive which is why you can see that this new graph that we created a sine squared Omega T does not go below the x-axis all right let's let's try a different kind of transformation we're gonna copy this down and this one is going to be sine of Omega times T plus K times sine of Omega times T now this is quite a cool one we also need a drop down we need a drop in K value and I'm gonna set my K between negative 10 and tip so when I plug that into K and then I plug that into you know we'll compare it to the normal sine curve so we'll just replace this value here and you'll notice you might not notice what it's doing just yet but as I shift through this you should be able to see what's going on I'll just sit this I'll make a copy of this and set it to negative 1 and 1 for now okay so what this is basically doing is it is skewing the sine curve we can either skew it forwards or we can skew it backwards so it's just moving this crest point or this trough point backwards and forwards which i think is a pretty neat sort of way to mess around with the sine curve and then we could plug in the rest of our values into W and then we could once again plug them into here let's see we'll plug it in to get we'll plug into the flip matrix and see what's coming out of here so now as we skew this back and forth now we're getting some really cool transformations and weaves and we can still ease there we go that's a really cool way to mess with psychos all right now let's transfer this into a surface so I'm going to make a new document I might just copy over all of these expressions and these values so I'll copy over the starter because we're gonna basically reuse all of this okay now I'm gonna create a rectangle on my plane doesn't matter how big you make it or whether it's the square or not just reference it into grasshopper using a normal curve and turn it into a surface also move all of this a bit further forward all right now we're going to divide the surface and before I go any further I'm gonna hide this curve I'm also going to go into perspective mode the surface as well and so this one it was straight actually I shouldn't have taken my side on my rectangle here's a really neat trick I'm gonna to get the dimensions of the surface I'm gonna use and divide the you spend the you length over the V links and then I'm gonna grab into just slider set that to 100 and then I'm gonna grab a multiplier I'm gonna multiply let's see my result by this slider value and I'm going to plug that into my youth I'm gonna plug the slide into my V so you might be wondering what I'm trying to do with this well basically this is a really cool is a really simple way that you can ensure that you'll always get a square or a square set of points as a result on your surface division so if I'm in if I'm just using a single slider you'll notice that I'm getting all these rectangular results out of all these points which is absolutely fine you can do that if you want but for me I like to get uniformity across the entire surface that I'm working with of course you could plug in two separate sliders and you could you know maybe bump that one up to 12 and then you'd sort of sit here and guess maybe maybe somewhere around 8 will give me a reasonably square result but uh if we do it like this then we can we're basically calculating the most square result possible given the values we have there we go you can see they're all still pretty square all right so that's that next we're going to take the surface and we're going to scale it up about Center so we find the center of the surface using the area component and we plug the center in and then I'm going to create another slider which has maximum value I am going to get them evaluate surface component and it's will plug our scaled result into here turn these off and now we want to evaluate the surface along its new limit in the direction and a really cool tool for doing this is the multi-dimensional slider we'll plug that into the UV and so now while you might not notice spinning results at the moment and that's because when to repr amateur eyes the six remember Reaper and rising surface turns the whole surface into zero to one coordinate plane so instead of this being whatever this being zero on the surface and this being two hundred eleven point seven this is 0 and this is 1 and this is 0 and this is 1 as well so when we evaluate the surface we can slide this any which way we want and get a result much simpler all right so now we are going to use a distance component to find the distance between this point and all of these points and I'm also going to flatten these points because we don't need the structure to them at the moment all right I'm also gonna take this number down just for now all right so now we've got a distance value and if we want we can now plug this into our parameter value and this will give us a whole lot of results for our side surface I'm just going to move these away so this will give us a list of values between negative 1 and 1 so I'm going to use those as an amplitude value of which to move all of these points from this list so plug my points into the geometry and I'll plug my victor into T and you won't notice anything straight away well you might actually you can see a bit of wave to that surface or to those points I'm gonna turn this off to make it easier to understand what's going on and now we're gonna use a surface from points component so this wants a list of flattened points um here's a here's a key thing to explain I'm just gonna unflattering this temporarily okay and now we for a surface we need to get the number of divisions in the U direction we need to plug an integer into here because sometimes there will be some rounding issues when we're trying to connect into the U value of our surface grid okay and so if you remember in the what tutorial was it I think it might have been in the data structures tutorial we talked about how anytime you're doing divisions the result is well the resulting number of points is always going to be your parameter value plus one so we're going to plug this into here and I'm gonna change this expression to u plus one get rid of the Y and change the x value to you and now when I recompute that we're now getting the result we want okay so if I plug this into my you you'll notice throws an error why is that the you count is not value valid for this amount of points and that's because we always need a flattened list of points coming in if we don't flatten it then grasshop cannot create a surface from all right so we've got a surface with the minimal amount of wave to it so I'm gonna add a multiplier in here you might be wondering why I didn't apply the multiplier straighten the expression and I'll explain that in a sec as well let's see so now as I increase this value you can start to see our sign a sign function starting to appear in the actual surface might look a bit sort of low raise at the moment so we can increase our number of divisions to get a look at it there we go really nice smooth sign surface now let's look at doing some sign sums so we'll copy these three values over here and then plug it all in and they've got okay so like we did with the what was it with one-dimensional sine functions we need to sort of merge these the data from these three results of these three values into one otherwise we're going to be getting looks like we're getting three different surfaces there so what we need to do is we need to bring in a friend flip matrix component there is and then we need to bring in either a mass multiplication or a mass addition so we'll plug those in and so that's gonna multiply all three of those results together and give us a 1 value and so now if we plug that into our our B result let's see before we do that we do need to get these into one list or else you'll see over here we've got three lists each each with two thousand eight hundred and sixty points if we were to plug in this component with two thousand eight hundred sixty lists we're gonna crash grass out there so we're just gonna flatten this here and we're getting flatten this here and then we're gonna plug it in and whoa now we're getting something really strange and so this is the results of Miss um different frequency values across the surface we can lower this I don't know how interactively we can do it just because it's fun computing a partner that's alright you can see we're really getting some interesting stuff going on as we slide through these values probably getting the most interesting result when we've got a lower lower period value of zeros probably too low and reasonably close results you'll get very interesting what else do I want to do after this yeah so what we could do next that is one way to do it but you'll notice that we're getting a sign this sort of the center of our sine function is clearly over here somewhere we can really understand that and what if we would add multiple sources you know maybe we could create something that more interesting so let's do that instead of having three period values we're gonna plug in three signs three values for our sine function generator over really quickly plug those in and I'm also going to need to graft the points coming into a and now we'll see what we get okay bit difficult to see what's going on and first we looks like we oh yes so at the moment they're all the exact that they're in the exact same place so let's move them around a bit well the amplitude is definitely way too high on neck so let's bring that right down somewhere and so now what we can get is we can basically get a really funky interference pattern which is just the result of sine waves coming from different sources this is a really cool pattern there's any number of things you can do with this you could get 3d print it you can see and see it I think we could also now that we've got three points we could replug in these three parameters and we'll make sure that our dash F is going to line up so we're going to graph the points coming in and there's three unique lists coming in so that's going to work absolutely fine and we preview on the surface okay now I'm going to take these values right down that is really weird we're getting you can almost see actually you can really see where the source of these points is coming from maybe I want to take it right off the surface so I'll bring it yes now actually I'll put it over here just off the surface and so as we adjust these we can get some really cool variation in the surface are they're getting like heaps of these crop crests and troughs or not very many at all my personal preference would probably be to have fewer because that can you can definitely see how that pattern starts to lose a lot of clarity as we start messing with it but let's just bake it out and have a look at it I think that is super cool all right let's let's take this up a notch and you know what we could we could try plugging in one of these maybe I'll try my sign my wave shifting algorithm for this we'll just use one of these for now and we'll just use one Omega value and so I'm gonna plug in my distance over here and then I'll plug this into my my multiplication result over here and I really need to take down the frequency that is really strange result just by I think oh okay I've never tried that before pushing my my period value negative that gives you some weird sort of some weird sort of shift in the same patterns that it alternates back and forth never ever thought of doing that but what I did want to do I wanted to keep my W value positive between zero and one I want to bring that right down and once again we can shape this surface however we want so that we're really pushing the extensive that we're really sort of skewing the sine curve one way or the other but if we would have punched these values up to negative 10 and 10 and you can start to get some really bizarre shifting happening yeah that's cool we sort of get one crest and then almost like a no I want to call it like a track a tire mark pen going in between up Chris that's that's really interesting and once again we could we could now plug this into a flip matrix and plug the result before I do that plug the wrong thing I don't want to plug my result in and they'll just enable these two guys here and let's see what we get really funky maybe I don't like that so much maybe I'll plug in some values for W it's not giving us too much variation maybe not as much as I hoped but it's doing something interesting along here but yeah like I've been saying just really just go nuts with sign codes there is so much out there so much material as well for just different ways you can transform a sine curve so you know just just have fun with it one last thing I'm going to show you is maybe a way that we can preview some of this geometry so what I'll do is I will go back to the original sine function and I sort of liked when we had these on and I might just manipulate this a little so we're getting what are we getting you know we're getting some sort of distinction of like a sine curve like wrists over here and then crests over here in a really cool way that they're adding together now instead of making these into a surface don't make them into a mesh mesh surface we need to do a mesh from the points so I'm going to plug my points into here I'm gonna plug my U value into the year and we're gonna do another one for the V I always like to label these just for consistency it makes it a bit easier to understand the definition here's our U value of here and we'll plug that in and so you might you might be wondering why I'm doing this and that will become clear in just just a second if we we're gonna look at also how we can use the custom preview not custom pre or a form of custom preview but we're gonna do it with a gradient I'm just gonna start by setting my gradient made me to something like this and then I'm gonna find the bounds of all the values of my mass addition and it tells me that all these values lie between negative two point nine seven so on and so forth two negative two point nine eight I'm sorry two positive two point nine eight and so we're gonna deconstruct that domain oh no not the domain squared just grab it from here in the math tab under domain deconstruct domain plug that in and then we'll plug our start and end into here so what this gradient does is if you plug in a lower limit and an upper limit it'll set those values to here so the start is saying it so that if this is negative three and this is positive three roughly what we what we're gonna get is when we plug in all our height values is we're gonna get a color out of this so what we can do right off the bat is Misha's have the ability to to add colors you can add color to a mesh through this but vertex color attribute you can't do that with surfaces or anything else so that makes missions really unique and so we can this is a really cool way to sort of visualize some of this data and so maybe I wanna you know I want to push the surround a bit so I get this green space and then I get all these tiny little pills with just a red peak and we could we could change the gradient pattern to something else maybe I like that a little bit better but yeah it's a really cool way that you can visualize a mess with data and then we could also just bake this out now we've got a nice colored mesh that we could render using Rhino render or we could take it into another program like 3ds max or something and keep messing around with it all right so this has been a look at sine functions in one dimension sine functions in two dimensions using sine transformations to make more complex surfaces wave interference patterns and we even finished off with a bit of custom preview using the gradient tool so I hope that this has been a good tutorial
Info
Channel: Daniel Christev
Views: 21,441
Rating: 5 out of 5
Keywords: tutorial, transform, sine, yt:quality=high, grasshoppper
Id: -Y3sPooABio
Channel Id: undefined
Length: 35min 56sec (2156 seconds)
Published: Thu Jan 21 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.