Jump to content
kiryha

Randomize point selection pattern

Recommended Posts

I am using modulus to add each 10th point to a group:

@group_targetPoints = 1;

if (@ptnum%10){
    i@group_targetPoints = 0;
    }


So I get evenly distributed points: 0, 10, 20, 30, ... etc. I wish to add or subtract a small number from each point number (like int(rand(@ptnum)*3)) to randomize distribution a bit. 
Have no idea how to solve this in this case. Adding a small random number to a modulus argument ( 10+int(rand(@ptnum)*3) breaks even pattern dramatically.

VEX_randomizeGroup.PNG

VEX_groupSelectRandomize_001.hipnc

Share this post


Link to post
Share on other sites
Posted (edited)

@group_targetPoints = 1;
int delta = 2;
i@modulo = 10 + int(ceil(delta * fit01(rand(@ptnum + 354656), -1, 1)));
if(@ptnum%@modulo) {
    i@group_targetPoints = 0;
}

I use delta to add or subtract the module 10. Here 10 +- a random between -2 to +2.

I think it's not the good way. This approach seems better:

@group_targetPoints = 0;
int delta = chi("delta");
i@modulo = int(ceil(delta * fit01(rand(@ptnum + 356156), -1, 1)));
if(@ptnum%30 == 0) {
    setpointgroup(0,"targetPoints", @ptnum + @modulo, 1);
}

Here for each modulo of 30, i setup in group another point near the point number.

Edited by fsimerey
  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

here's mine.

var means -/+ var to your given number.

(ideally there should be a check to ensure the var doesn't exceed mod/2...otherwise, neighbours could encroach each other...but you might not care about this...)
 

int pts[] = primpoints(0,0);

foreach(int i; pts)
{
    if(i%chi("mod")==0) // even distribution
    {
        // now add a little offset
        int range = chi("var")+1;
        int vari = fit01(rand(i+ch("seed")),-range,range);
        setpointgroup(0,"sel",i+vari,1);

    }
}

 

vu_ModSel.hipnc

Edited by Noobini
  • Like 1

Share this post


Link to post
Share on other sites

you can add a 'shift' if you like

foreach(int i; pts)
{
    if((i+chi("shift"))%chi("mod")==0) // even distribution
    {
        // now add a little offset
        int range = chi("var")+1;
        int vari = fit01(rand(i+ch("seed")),-range,range);
        setpointgroup(0,"sel",i+vari,1);

    }
}

 

  • Like 1

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

×