dolexd Posted October 21, 2020 Share Posted October 21, 2020 Hello, I am trying to select two primitives (105 - 106 from the image attached) based on the angle but I am not sure how. I have tried the group and delete but I can't get it to work. Can anyone please help? Since the primitive number changes based on an external attribute (height), I can't just select these two and group them. Thank you for your help. Quote Link to comment Share on other sites More sharing options...
animatrix Posted October 22, 2020 Share Posted October 22, 2020 Hi, You can first group the edges using a Point Wrangle: float getAngleBetweenVectors ( vector v0; vector v1 ) { vector v0n = normalize ( v0 ); vector v1n = normalize ( v1 ); return atan2 ( length ( cross ( v0n, v1n ) ), dot ( v0n, v1n ) ); } int pts [ ] = neighbours ( 0, @ptnum ); foreach ( int pt; pts ) { if ( @ptnum < pt ) continue; int prs [ ] = { }; int firsthedge = pointhedge ( 0, @ptnum, pt ); int count = hedge_equivcount ( 0, firsthedge ); if ( count == 2 ) { int hedge = firsthedge; do { int pr = hedge_prim ( 0, hedge ); if ( pr != -1 && find ( prs, pr ) < 0 ) append ( prs, pr ); hedge = hedge_nextequiv ( 0, hedge ); } while ( hedge != firsthedge ); vector n0 = primuv ( 0, "N", prs [ 0 ], 0.5 ); vector n1 = primuv ( 0, "N", prs [ 1 ], 0.5 ); float angle = getAngleBetweenVectors ( n0, n1 ); if ( angle >= radians ( ch("minangle") ) ) setedgegroup ( 0, chs("vex_selectiongroup"), @ptnum, pt, 1 ); } } Then convert this edge group into a primitive group using a Primitive Wrangle after setting the Group parameter to the resulting edge group: i@group_newprims = 1; Quote Link to comment Share on other sites More sharing options...
dolexd Posted October 22, 2020 Author Share Posted October 22, 2020 Hey Thanks, I will try this out. I am still new to programming in VEX and this is good to run through line by line. Hopefully I am able to follow through. Thanks, Quote Link to comment Share on other sites More sharing options...
krishna avril Posted October 23, 2020 Share Posted October 23, 2020 If you have an attribute, you can group using that attrib if(@attrib>x){ i@group_groupcustomname=1; } Quote Link to comment Share on other sites More sharing options...
dolexd Posted November 1, 2020 Author Share Posted November 1, 2020 Great. Thanks a lot. This helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.