Jump to content

Randomize point selection pattern


kiryha

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

Link to comment
Share on other sites

@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
Link to comment
Share on other sites

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