Deleting the shorter edge of a rectangle
2947 9 2- joolean_boolean
- Member
- 5 posts
- Joined: 10月 2019
- Offline
Hello dear Houdini artists,
I'm relatively new to Houdini and still struggling with some of the more basic concepts.
My problem is the following: I have a rectangle (created from a bound node) and I want to delete either the shorter or the longer edge of that rectangle, so that I can then create a vector that shows me the orientation of that rectangle.
How would I go about doing that? I have measured the lengths of the rectangle with a convert line node, but how can I compare the 2 lengths and remove one or the other?
Is there a better way to go about this?
I would really appreciate some help with this.
Best regards,
Julian
I'm relatively new to Houdini and still struggling with some of the more basic concepts.
My problem is the following: I have a rectangle (created from a bound node) and I want to delete either the shorter or the longer edge of that rectangle, so that I can then create a vector that shows me the orientation of that rectangle.
How would I go about doing that? I have measured the lengths of the rectangle with a convert line node, but how can I compare the 2 lengths and remove one or the other?
Is there a better way to go about this?
I would really appreciate some help with this.
Best regards,
Julian
- tamte
- Member
- 8837 posts
- Joined: 7月 2007
- Offline
julianbragagnaYou can then use Sort SOP to sort prims by your length attribute
I have measured the lengths of the rectangle with a convert line node, but how can I compare the 2 lengths and remove one or the other?
And then Blast SOP to keep or delete primitives: 0 1
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- tamte
- Member
- 8837 posts
- Joined: 7月 2007
- Offline
julianbragagnaYou can then use Sort SOP to sort prims by your length attribute
I have measured the lengths of the rectangle with a convert line node, but how can I compare the 2 lengths and remove one or the other?
And then Blast SOP to keep or delete primitives: 0 1
As those will be the shortest 2
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- joolean_boolean
- Member
- 5 posts
- Joined: 10月 2019
- Offline
- tamte
- Member
- 8837 posts
- Joined: 7月 2007
- Offline
- Houdini Obsession
- Member
- 58 posts
- Joined: 11月 2014
- Offline
julianbragagna
How would I go about applying this on scale, for an arbitrary number of rectangles?
using the rest length prim attribute generating form the convertline can sort multiple rectangles with the same blast or delete node
if u precisely need per rectangle sort then go with tamte suggestion
Edited by Houdini Obsession - 2021年5月7日 10:59:23
Houdini Fx Artist (Build)
- tamte
- Member
- 8837 posts
- Joined: 7月 2007
- Offline
- Konstantin Magnus
- Member
- 686 posts
- Joined: 9月 2013
- Online
julianbragagna
Is there a better way to go about this?
To obtain the short direction you could unroll your rectangles and subtract their minimal position from the primitive's center:
v@dir = normalize(minpos(1, v@P) - v@P);
To obtain the long direction you would calculate the cross product of the short direction and the primitive's normal:
vector nml = prim_normal(0, i@primnum, vector(0.0)); v@perp = normalize(cross(v@dir, nml));
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
- Konstantin Magnus
- Member
- 686 posts
- Joined: 9月 2013
- Online
Alternatively you could iterate through the primitive's points, and compare the subtractions of their point positions:
int pts[] = primpoints(0, i@primnum); vector pos_0 = point(0, 'P', pts[0]); vector pos_1 = point(0, 'P', pts[1]); vector pos_2 = point(0, 'P', pts[2]); vector dir_10 = pos_1 - pos_0; vector dir_21 = pos_2 - pos_1; v@dir_short; if(length(dir_10) > length(dir_21)){ v@dir_short = normalize(dir_21); } else{ v@dir_short = normalize(dir_10); }
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
- Houdini Obsession
- Member
- 58 posts
- Joined: 11月 2014
- Offline
-
- Quick Links