Arthur Spooner Posted May 11, 2016 Share Posted May 11, 2016 I'm having problem simply understanding the documentation; The random function in VEX, how do I read it and apply it ? float random(int position) Isn't the correct VEX code; float random(@P.y) for a simple example on a sphere and that would randomize the points on a sphere ? Quote Link to comment Share on other sites More sharing options...
6ril Posted May 11, 2016 Share Posted May 11, 2016 aouch ! what are you trying to say ???? randomize the point on a sphere? your sentence make no sense... or is it my english? read it the doc like this (I think): float random(int position) -> result will be a float, a random value based on an integer of your choice. So from the line you wrote: float random(@P.y) I guess you are trying to randomize the Y position of the points on a sphere .... right ? then you should type this : @P.y = random(@ptnum); if the doc tells you to put an integer, don't put a float. @P.y is a float value. so you know what is a float ? an integer ? what are the rgb values of red? Quote Link to comment Share on other sites More sharing options...
Maurits Posted May 11, 2016 Share Posted May 11, 2016 (edited) I think you can put in a float but it will be converted to a int so it would still work. But you don't have exact control on hw it's converted to an int. So you would have to use Ceil, floor, round or int to get control how it's done. Never mind my comment above forgot about the fact that random is an overloaded function. Edited May 15, 2016 by Maurits Quote Link to comment Share on other sites More sharing options...
6ril Posted May 12, 2016 Share Posted May 12, 2016 right... just take the info and run... that will teach me to help this guy... Quote Link to comment Share on other sites More sharing options...
haggi Posted May 13, 2016 Share Posted May 13, 2016 On 5/11/2016 at 2:04 AM, Arthur Spooner said: I'm having problem simply understanding the documentation; The random function in VEX, how do I read it and apply it ? float random(int position) Isn't the correct VEX code; float random(@P.y) for a simple example on a sphere and that would randomize the points on a sphere ? I suppose you are confused by the name "position". It does not necessarily means a real position of your points, it can be any value. Internally the value is interpreted as a position in some N dimensional space. That's the reason why it is called "position". e.g. you can do something like this: float result = random(@Frame + @ptnum); Quote Link to comment Share on other sites More sharing options...
old school Posted May 13, 2016 Share Posted May 13, 2016 The confusion lies in the fact that you are using the random() variadic form: vector random(vector position). @P is an internally defined vector type variable so the random(@P) will return a vector. Variadic functions are used for a great variety of vex functions where the type of declared variable used as one of the input parameters to the function determine what type of function is called and what the return value is. When we create our own VOP HDA's, you can add variadic forms by using "signatures" and code references in the body of the function. https://en.wikipedia.org/wiki/Variadic_function The random() function has a great many variadic forms. Have a look at the help here: http://www.sidefx.com/docs/houdini15.0/vex/functions/random This is why you use the help when you are learning to write vex. Nothing stopping us from sneaking in a couple extra variadic types between releases... Again ALWAYS USE THE HELP when writing vex. Even old school vex peeps ALWAYS USE THE HELP. 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.