Select edges whether horizontal or vertical

   7269   7   2
User Avatar
Member
4 posts
Joined: 4月 2020
Offline
Hello,

How would you select edges by their direction ?



Playing with normals doesn't give me an interesting result as every point share the same normal angle.

Guillaume

Attachments:
unknown.png (404.3 KB)

User Avatar
Member
4730 posts
Joined: 2月 2012
Offline
Hi,

You can write something like this in a Point Wrangle:

vector n = normalize ( chv("v") );
float tolerance = ch("tolerance");

int pts [ ] = neighbours ( 0, @ptnum );
foreach ( int pt; pts )
{
    if ( @ptnum < pt )
    {
        vector p = point ( 0, "P", pt );
        vector dir = normalize ( @P - p );
        if ( abs ( abs ( dot ( dir, n ) ) - 1 ) <= tolerance )
            setedgegroup ( 0, "edges", @ptnum, pt, 1 );
    }
}

N is the direction you want to select edges from, and tolerance allows you to include only edges that are parallel to N (0) or perpendicular to N (1), or anything in between.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
555 posts
Joined: 2月 2017
Offline
i modded the code to this cos i find it easier to understand

vector n = normalize ( chv("v") );
float tolerance = ch("tolerance");

int pts [ ] = neighbours ( 0, @ptnum );
foreach ( int pt; pts )
{
    if ( @ptnum < pt )
    {
        vector p = point ( 0, "P", pt );
        vector dir = normalize ( @P - p );
        if ( 1 -  abs(dot ( dir,n )) <= tolerance )
            setedgegroup ( 0, "edges", @ptnum, pt, 1 );
    }
}
}
coz both dir and n are normalised, their dot product will never ever be greater than 1…so 1 - dot is much easier to digest to me.
i'm just a hobbyist tho so don't take me too seriously.
User Avatar
Member
19 posts
Joined: 3月 2020
Offline
vusta
i modded the code to this cos i find it easier to understand

vector n = normalize ( chv("v") );
float tolerance = ch("tolerance");

int pts [ ] = neighbours ( 0, @ptnum );
foreach ( int pt; pts )
{
    if ( @ptnum < pt )
    {
        vector p = point ( 0, "P", pt );
        vector dir = normalize ( @P - p );
        if ( 1 -  abs(dot ( dir,n )) <= tolerance )
            setedgegroup ( 0, "edges", @ptnum, pt, 1 );
    }
}
}
coz both dir and n are normalised, their dot product will never ever be greater than 1...so 1 - dot is much easier to digest to me.
i'm just a hobbyist tho so don't take me too seriously.

Hi everyone! found this useful!

there is a missing bracket after " if ( 1 - abs(dot ( dir,n )) <= tolerance )"

thought someone might have trouble running the wrangle.

Thanks!
User Avatar
Member
6 posts
Joined: 7月 2018
Offline
hello
I'm having a hard time running the wrangle, can someone attache here the hip file, please?
Thank you very much
User Avatar
Member
30 posts
Joined: 4月 2015
Offline
Matan_Shilo
hello
I'm having a hard time running the wrangle, can someone attache here the hip file, please?
Thank you very much

Same here. I'm getting a rather odd error though the code seems legit.
"Error: Vex error: Preloaded shader is invalid. "
User Avatar
Member
4730 posts
Joined: 2月 2012
Offline
Robot_and_Robot
Matan_Shilo
hello
I'm having a hard time running the wrangle, can someone attache here the hip file, please?
Thank you very much

Same here. I'm getting a rather odd error though the code seems legit.
"Error: Vex error: Preloaded shader is invalid. "

The code I posted compiles.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
9 posts
Joined: 4月 2009
Offline
Hello all
Three years late but better than never.
A student of mine was asking about selecting edges procedurally to polybevel.
After failing to find a solution with the group SOP, I found animatrix's wrangle solution.
At first, I too had the same weird 'shader error', but after some troubleshooting and clearing the extra brace added by vusta,
I managed to get things to work and added some comments in this example file in my journey to understand the code.
It is not fully procedural but it is a way forward instead of manual selection.

Hope it helps others jumping into this in future as I have done this Dec 2023.

p/s you have to click on the top right button in the point wrangle SOP to create the spare parameters after you paste the code.

Michael Ng
Nanyang Polytechnic
Edited by michaelngeb - 2023年12月7日 22:19:41

Attachments:
grouping edges procedurally.hipnc (121.4 KB)

  • Quick Links