Jump to content

PtNum Shuffle?


Justin K

Recommended Posts

Hey All, 

Simple question here.  If you have a line, can you randomize the ptnum using only the existing ptnum values (0-24) and associated P positions?  So ptnum 1 (0,4,0) is now ptnum 7 (0,12,0), ptnum 3 is now (0,12,0), replacing ptnum 12, etc.  I know you can do this with a Sort Sop (random) but I'd like to do it in a Vex Sop Specifically, and then in a wrangle afterwards--its a tech challenge thing.  I feel like this is simple and Im missing something pretty basic.  

 

Also, bonus question, what is the difference between ptnum and id in vop globals?  They are behaving as if they were the same thing when I am running orders (say random) across points.  

Thanks!

Edited by JKeil
Link to comment
Share on other sites

Hm, sorting using random gives you actually similar thing as if you do:

@myindex = rand(@ptnum); (this is in pointwranglenode)

and now you can use sort node but instead random choose sort by attribute and enter myindex as name for it. If you are familiar with math you can also try

something like:

@myindex = cos(2 * 3.1415926 * @ptnum / float(@numpt));

or any other, your, function to calculate values of myindex which when sorted gives you order you want.

ptnum is the basically index of point in some node and it is NOT "stick" to point. So for example if you have line with 10 points (ptnum goes from 0 to 9) and if you delete some point in the middle of the line you will see (in spreadsheet) that number of points is decreased (and become 0 to 8). It is simple counter of points after some operation. In general, any node which result affects the point count will make ptnum "floats" over points. Think on it as simple array from zero to numpt-1 without "holes" in it. All numbers are there.       

@id is attribute, same as your custom attribute let say @myindex and it is stick to point. So for example if your line of 10 points initially have @index attribute equal to @ptnum, when you delete let say point with @ptnum=4 (or @index=4 same thing) remaining 9 points will have ptnum from 0 to 8 (because it is simple counter of remaining points) while @index attribute on those 9 points will be: 0,1,2,3,5,6,7,8,9

 

   

  

Link to comment
Share on other sites

On 11/18/2017 at 1:58 AM, djiki said:

Hm, sorting using random gives you actually similar thing as if you do:

@myindex = rand(@ptnum); (this is in pointwranglenode)

and now you can use sort node but instead random choose sort by attribute and enter myindex as name for it. If you are familiar with math you can also try

something like:

@myindex = cos(2 * 3.1415926 * @ptnum / float(@numpt));

or any other, your, function to calculate values of myindex which when sorted gives you order you want.

ptnum is the basically index of point in some node and it is NOT "stick" to point. So for example if you have line with 10 points (ptnum goes from 0 to 9) and if you delete some point in the middle of the line you will see (in spreadsheet) that number of points is decreased (and become 0 to 8). It is simple counter of points after some operation. In general, any node which result affects the point count will make ptnum "floats" over points. Think on it as simple array from zero to numpt-1 without "holes" in it. All numbers are there.       

@id is attribute, same as your custom attribute let say @myindex and it is stick to point. So for example if your line of 10 points initially have @index attribute equal to @ptnum, when you delete let say point with @ptnum=4 (or @index=4 same thing) remaining 9 points will have ptnum from 0 to 8 (because it is simple counter of remaining points) while @index attribute on those 9 points will be: 0,1,2,3,5,6,7,8,9

 

   

  

Thanks for the post, makes perfect sense

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...