Getting normals to point inside a path, got a solution, wanna know if there is a more effective one

   1571   6   1
User Avatar
Member
15 posts
Joined: July 2013
Offline
Hi,

I'm trying to get normals to point inside a path.

To achieve that I did a little hack:

  • poly extude the path to get like a stipe
  • find the nearest point and calculate a vector from it
  • steal the normals back to the original path

Here is the result:


I was wondering if there is a better way to do that ?
Only in vex ? without the polyextrude if possible…

Thanks
Edited by Ziboo - Nov. 12, 2018 16:20:20

Attachments:
2018-11-12 16_18_36-C__Users_RobinB_Desktop_GetNormalsPointingInsideSurface.hipnc - Houdini Apprenti.png (104.1 KB)

User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
What do you mean by “normals to point inside a path”?
You mean you want to find the bisector vector for every angle?

Check this file: it's only vex, it finds the bisectors, but there's one problem: some are pointing outwards, some inwards.

Should be a good start, you can try to fix it.
Would like to know how to. Update with your solution if you find any

cheers

Attachments:
bisect.hiplc (134.5 KB)

User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
ps. added new non-vex method, which still uses polyextrude, but no attribute transfer

Attachments:
bisect1.hiplc (141.8 KB)

User Avatar
Member
15 posts
Joined: July 2013
Offline
Hi Andr,

Thanks for the answer.
I had the same setup than you before, and ended up with the same issue. Some normals are fliped.
Maybe I wasn't super clear.

What I'm wondering is how does polyextrude find thoses vectors ? and they all align towards the same direction (interior or exterior, depending on the distance)
Edited by Ziboo - Nov. 13, 2018 09:59:17

Attachments:
houdinipolyextrude.jpg (61.8 KB)

User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
maybe we can then iterate through every normal using a dot(thisNormal, nextNormal).
If dot product < 0 then flip nextNormal.

Given that my guess is right (I'm not really sure honestly), I tried this code in a detail attribute wrangle:
for(int i = 0; i<@numpt; i++)
{
    vector thisN = point(0, "N", i);
    vector nextN = point(0, "N", i+1);
    if( dot(thisN, nextN)<0)
    {
        setpointattrib(0, "N", i+1, -nextN);
    }
    
}


There's a problem, when you set N on nextpoint, in the following iteration the currentPoint will still have its original N, because I believe you can't modify geometry on the fly with Vex.
So maybe we should create a variable in the loop to store the nextN for the next cycle. But I'm lazy to do it now
Edited by Andr - Nov. 13, 2018 10:30:09
User Avatar
Member
15 posts
Joined: July 2013
Offline
I don't think that's gonna work.
The more I look at it, the more I see that it's more complex.
I actually need to find if an angle between 3 points is convex or concave to know how to orient the normal..

Anyone else would have try ?

Thanks
User Avatar
Member
15 posts
Joined: July 2013
Offline
Ok got it working in one vex node.
Only thing is that the path needs to be 2D, has soon has points don't have the same Y, the result is wrong.
But getting close

Attachments:
2018-11-13 13_56_18-C__Users_RobinB_Desktop_GetNormalsPointingInsideSurface.hipnc - Houdini Apprenti.png (106.3 KB)

  • Quick Links