Randomize Normal attribute using attribWrangle

   431   2   0
User Avatar
Member
48 posts
Joined: Feb. 2013
Offline
I want to create a Normal attributes with random value. I can use attribNoise but I want to try using attribwrangle. I use this code to get random value to N :

@N = rand(@P) ;

It works but since the random generate value from 0 to 1, I want to convert to -1 to 1 range simply multiply it by 2 then subtract by 1 :

@N = (rand(@P) *2 ) -1 ;

But I got identical result for all the x,y and z. I also tried using fit() but got same problem. What is the proper way to do it ?
User Avatar
Member
143 posts
Joined: May 2017
Offline
Since you are operating with individual floats, it is sometimes not clear what the result should be. Use an explicit type cast like this:

@N = vector(rand(@P)) * 2 - 1;
User Avatar
Member
48 posts
Joined: Feb. 2013
Offline
@
viklc
Since you are operating with individual floats, it is sometimes not clear what the result should be. Use an explicit type cast like this:

@N = vector(rand(@P)) * 2 - 1;

it works! Thanks a lot.
  • Quick Links