Jump to content

connecting points avoiding other points with same id


Javier31

Recommended Posts

Hello everyone,

Hopefully, someone can help me with this one :-)

I do have a bunch of particles flying upwards and creating a trail of points behind them that i connect as polylines with the trail SOP. (see attached image)

Then i scatter some points on these lines. These new points inherit the id of the original particle and what i would like to to do is to use these id's to control a nearpoints function in order to connect with the nearest points except with the points that have the same id (basically i want to connect with those points that are not in the same line as the point that searches

i attach a file and an screenshot of what i have so far

Any help would be really appreciated! cheers!!

1.JPG

connecting just to other lines.hipnc

Link to comment
Share on other sites

Thanks a lot but I'm sorry i completely forgot to mention that i don't want to include in the "search" for nearest points those with same id neither

if not I will always have points finding many points that have the same id and not creating any connection at all unless i increase the total amount of point to search - something I would like to keep low as 2 or 3 max per point 

Basically, every single point should be able to make 2 or 3 connections max with points of different id 

:-) cheers!

2.JPG

Edited by Javier31
Link to comment
Share on other sites

Add pointwrangle after popnet

setpointgroup(0, sprintf("pg%d", @ptnum), @ptnum, 1);
i@gr = @ptnum;

chenge attribwrangle2 to
 

int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3);

foreach(int ele; nps){
    int line = addprim(0,"polyline");
    addvertex(0,line,@ptnum);
    addvertex(0,line,ele);
}

Sorry can't upload the file, odforce....

Link to comment
Share on other sites

Add pointwrangle after popnet

setpointgroup(0, sprintf("pg%d", @ptnum), @ptnum, 1);
i@gr = @ptnum;

chenge attribwrangle2 to
 

int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3);

foreach(int ele; nps){
    int line = addprim(0,"polyline");
    addvertex(0,line,@ptnum);
    addvertex(0,line,ele);
}

Sorry can't upload the file, odforce....

connecting just to other lines_v02.hipnc

Edited by fencer
Link to comment
Share on other sites

Oh man this is amazing many thanks! :-)

Do you mind if i ask you about this line? // 

int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3);

i have checked sprintf in the VEX documentation and it seems to appear with just one argument sprintf(___) instead of sprintf(____,____) as you are writing. I am aware that @gr is @ptnum but can you briefly explain that a little bit?

ALso.. what does  "* ^pg%d"  mean? 

Apologise for my ignorance.. really! :-)

Many thanks

 

Link to comment
Share on other sites

1 hour ago, Javier31 said:

Oh man this is amazing many thanks! :-)

Do you mind if i ask you about this line? // 


int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3);

i have checked sprintf in the VEX documentation and it seems to appear with just one argument sprintf(___) instead of sprintf(____,____) as you are writing. I am aware that @gr is @ptnum but can you briefly explain that a little bit?

ALso.. what does  "* ^pg%d"  mean? 

Apologise for my ignorance.. really! :-)

Many thanks

 

int [] nearpoints(string geometry, string ptgroup, vector pt, float maxdist, int maxpts)

ptgroup - group mask
* - all, ^ - except
result will be all point except in group (pg0 or pg1 or pg2...)

sprintf("* ^pg%d", @gr)

http://www.cplusplus.com/reference/cstdio/sprintf/
pg-symbols, %d - argument
in your case %d = @gr = id of line
 

Link to comment
Share on other sites

1 hour ago, Javier31 said:

Oh man this is amazing many thanks! :-)

Do you mind if i ask you about this line? // 


int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3);

i have checked sprintf in the VEX documentation and it seems to appear with just one argument sprintf(___) instead of sprintf(____,____) as you are writing. I am aware that @gr is @ptnum but can you briefly explain that a little bit?

ALso.. what does  "* ^pg%d"  mean? 

Apologise for my ignorance.. really! :-)

Many thanks

 

int [] nearpoints(string geometry, string ptgroup, vector pt, float maxdist, int maxpts)

ptgroup - group mask
* - all, ^ - except
result will be all point except in group (pg0 or pg1 or pg2...)




			
		
Link to comment
Share on other sites

1 hour ago, Javier31 said:

Oh man this is amazing many thanks! :-)

Do you mind if i ask you about this line? // 


int nps[] = nearpoints(0, sprintf("* ^pg%d", @gr), @P, 100, 3);

i have checked sprintf in the VEX documentation and it seems to appear with just one argument sprintf(___) instead of sprintf(____,____) as you are writing. I am aware that @gr is @ptnum but can you briefly explain that a little bit?

ALso.. what does  "* ^pg%d"  mean? 

Apologise for my ignorance.. really! :-)

Many thanks

 

int [] nearpoints(string geometry, string ptgroup, vector pt, float maxdist, int maxpts)

ptgroup - group mask
* - all, ^ - except
result will be all point except in group (pg0 or pg1 or pg2...)




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