Jump to content

VEX docs


Arthur Spooner

Recommended Posts

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?

 

Link to comment
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
Link to comment
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);

 

Link to comment
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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...