Removing points based on line detection

   4861   7   2
User Avatar
Member
18 posts
Joined: Sept. 2019
Offline
Is there a way to detect and delete the points circled in red?

Notice how all non circled points have their normals aligned to the connected line? If there is no more line in the direction of the normal, I would like to delete the point.

Does anyone have an idea how to achieve this?
Edited by lawindh - Nov. 17, 2019 20:45:59

Attachments:
DeletePoints.PNG (167.7 KB)

User Avatar
Member
18 posts
Joined: Sept. 2019
Offline
Messed around with this for a while and had an idea. I'm guessing that maybe I can use an intersect. I tried setting one up but be warned, my vex skills are that of a newbie.

What I am trying to achieve is to use the normal as my ray direction, cast a ray from each point using the lines as the intersect geo, then if nothing is detected then a -1 should be returned. Next I want to delete that point. What am I doing wrong here? Or is there a better way?

Attachments:
deleteByIntersect.JPG (130.6 KB)

User Avatar
Member
682 posts
Joined: Sept. 2013
Online
Try deleting by normal length:

if(length(v@N) > 0.1){
	removepoint(0, i@ptnum, 1);
}

And next time please share the HIP file so people can help you more easily.
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
143 posts
Joined: Oct. 2015
Offline
Hello ,
you could first group by neighbors count as those point have only one
neighbourcount(0,@ptnum)<2
then iterate on this group and compare first neighbor direction with normal :

vector dir =point(0,“P”,neighbour(0,@ptnum,0))-point(0,“P”,@ptnum);
if(normalize(dir)!=normalize(v@N)){
removepoint(0,@ptnum);
}

or with a dot product to enable a little margin of error…
User Avatar
Member
18 posts
Joined: Sept. 2019
Offline
Benjamin Lemoine
Hello ,
you could first group by neighbors count as those point have only one
neighbourcount(0,@ptnum)<2
then iterate on this group and compare first neighbor direction with normal :

vector dir =point(0,“P”,neighbour(0,@ptnum,0))-point(0,“P”,@ptnum);
if(normalize(dir)!=normalize(v@N)){
removepoint(0,@ptnum);
}

or with a dot product to enable a little margin of error…

You nailed it!! This is working for me. Thanks so much. I'm a little confused on the dir vector and normalize sections, but I'll dig into them and see if I can make sense of how they are working.
Edited by lawindh - Nov. 18, 2019 15:15:01
User Avatar
Member
143 posts
Joined: Oct. 2015
Offline
The dir vector is first neighbor position (that mean the only neighbor for extremity) minus current point position : that give a vector pointing from my position to the neighbor… So the direction of the line…
User Avatar
Member
18 posts
Joined: Sept. 2019
Offline
Benjamin Lemoine
The dir vector is first neighbor position (that mean the only neighbor for extremity) minus current point position : that give a vector pointing from my position to the neighbor… So the direction of the line…

Oh yeah, that makes sense. Thanks for the explanation as well. It helps a lot.
User Avatar
Member
11 posts
Joined: Dec. 2013
Offline
//primitive wrangle
int primpts[] = primpoints(0,@primnum);
removepoint(0,primpts[-1]);
  • Quick Links