Jump to content

Recommended Posts

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 ?

Share this post


Link to post
Share on other sites

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?

 

Share this post


Link to post
Share on other sites

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 by Maurits

Share this post


Link to post
Share on other sites

right... just take the info and run...

that will teach me to help this guy...

Share this post


Link to post
Share on other sites
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);

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×