Randomizing points randomly using POintSOP

   9707   5   3
User Avatar
Member
436 posts
Joined: July 2005
Offline
Hi

I have point clouds.
Now I want to randomize the X and Z positions of points randomly.

I read the point cloud using File SOP
To this File SOP I append PointSOP
In Point tab under Position I have following expressions
$TX + (rand($F)*1000)
$TZ + (rand($F)*1000)

IT works, kind of. All the points in point cloud displace. What I would like is to have random points move randomly

Thanx

Dave
User Avatar
Member
7732 posts
Joined: July 2005
Offline
From “exhelp rand”:
float rand (float value)
Gives a pseudo-random number between 0 and 1 depending on the value.
If the same value is used the same number will result each time. A
different number is returned if fractional values are different.

i.e. rand(12.1) gives a different result than rand(12.2)


The key thing to note here is the part where it says “If the same value is used, the same number will result each time”. So since you passed the same value to rand for both tx and tz, $F, those calls to rand will give you back the same random number. So try using something like rand($F*2) instead for tz to get a different number.
User Avatar
Member
9 posts
Joined: July 2005
Offline
Ed's multiply is fine but I have always used random offsets like:


$TX + (rand($F + 1.01)*1000)
$TZ + (rand($F + 10.01)*1000)


Since rand goes from 0 to 1, you will certainly see a skew to the upper right looking down the z axis.

To fix that, use the fit function as follows:


$TX + fit(rand($F + 1.01), 0, 1, -1, 1)*1000
$TZ + fit(rand($F + 10.01), 0, 1, -1, 1)*1000


The fit works like this:

fit (float num, float oldmin, float oldmax, float newmin, float newmax)
Return a number between newmin and newmax that is relative
to num in the range between oldmin and oldmax. If the value is
outside the old range, it will be clamped to the new range.

eg. fit(3,1,4,5,20)=15

see also: fit01 fit11 fit10
User Avatar
Member
436 posts
Joined: July 2005
Offline
Thanx

As great as your advice is, it still does the same thing. That is all the points in the point clous displace by same amount at same frame, so it looks like object movement. I am trying to move random points by random amounts, in random directions, excluding Y axis.

Dave R
User Avatar
Member
344 posts
Joined: July 2005
Offline
You need something that will change the seed for the random number generator for each point at each frame. You could try seeding the random number generator with the frame number and the point number.

rand($F+$PT)

That should make the rand function a bit more random. It should spit out different values for each point individually at each frame.
Edited by - May 16, 2003 01:58:57
User Avatar
Member
344 posts
Joined: July 2005
Offline
Oh, and if you want different random values for the different axis of the same point, you'll need to expand the expession a little bit for one or both axis.

$TX+(rand($F+$PT)*1000)
$TZ+(rand(($F+$PT)*0.6)*1000)

and you can use the fit function described above to limit the result a bit.

$TX+(fit((rand(($PT+$F)*.3)), 0, 1, -.2, .2))

Sorry about the excessive bracing. It was th only way I could get it to evaluate right. Also, note you should use $PT+$F. I tried $PT*$F and it seems that there is a point number 0, so if you multiply you could end up with a point that doesn't move at all, if point 0 is in the point group you are displacing.
  • Quick Links