Linguininess Posted July 23, 2021 Share Posted July 23, 2021 hello! so I am trying to come up with an expression that combines the random and sin functions. I am trying to mimic something like morse code. It's either on or off....but with a falloff. Can someone help? Thanks Quote Link to comment Share on other sites More sharing options...
animatrix Posted July 23, 2021 Share Posted July 23, 2021 Hi, You can write something like this: float radius = ch("radius"); float amp = ch("amplitude"); float seed = ch("seed"); int count = chi("count"); for ( int i = 0; i < count; ++i ) { float r = rand ( i + 34.13 + seed ); vector p = primuv ( 0, "P", 0, r ); float d = distance ( p, @P ); float d2 = fit ( d, 0, radius, 0, PI ); float y = amp + sin ( d2 + 0.5 * PI ) * amp; if ( d < radius ) @P.y += y; } 1 Quote Link to comment Share on other sites More sharing options...
Linguininess Posted July 23, 2021 Author Share Posted July 23, 2021 this is great, thanks! how would I configure this setup to output the x value of this curve to just a single float value to be plugged into a parameter? Quote Link to comment Share on other sites More sharing options...
animatrix Posted July 23, 2021 Share Posted July 23, 2021 There are many ways, but the easiest is to sample the resulting curve using a float parameter like this: primuv("../attribwrangle1/", 0, "P", 1, ch("pos"), 0) This would be the expression you use in your parameter. Then you can control where to sample using another float parameter (normalized) called pos for example. This could be the current time also if you want, or you can animate the curve while sampling the same location on the curve. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.