Jump to content
Javier31

connecting points avoiding other points with same id

Recommended Posts

Javier31    0

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

Share this post


Link to post
Share on other sites
fencer    84

?

foreach(int ele; nearpoints(0,@P,5)){
    if(point(0, "id", ele) != @id){
        int line = addprim(0,"polyline");
        addvertex(0,line,@ptnum);
        addvertex(0,line,ele);
    }
}

 

Share this post


Link to post
Share on other sites
fencer    84

?

foreach(int ele; nearpoints(0,@P,5)){
    if(point(0, "id", ele) != @id){
        int line = addprim(0,"polyline");
        addvertex(0,line,@ptnum);
        addvertex(0,line,ele);
    }
}

 

Share this post


Link to post
Share on other sites
fencer    84

?

foreach(int ele; nearpoints(0,@P,5)){
    if(point(0, "id", ele) != @id){
        int line = addprim(0,"polyline");
        addvertex(0,line,@ptnum);
        addvertex(0,line,ele);
    }
}

 

Share this post


Link to post
Share on other sites
Javier31    0

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

Share this post


Link to post
Share on other sites
fencer    84

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

Share this post


Link to post
Share on other sites
fencer    84

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

Share this post


Link to post
Share on other sites
Javier31    0

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

 

Share this post


Link to post
Share on other sites
fencer    84
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
 

Share this post


Link to post
Share on other sites
fencer    84
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...)




			
		

Share this post


Link to post
Share on other sites
fencer    84
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...)




			
		

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

×