Deleting the shorter edge of a rectangle
3906
9
2
2021年5月6日 11:25
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
Attachments:
rectangle_problem.JPG (24.8 KB)
tamte
Member
9390 posts
Joined: 7月 2007
オフライン
2021年5月7日 9:55
julianbragagna 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?You can then use Sort SOP to sort prims by your length attribute
And then Blast SOP to keep or delete primitives: 0 1
Tomas Slancik CG Supervisor Framestore, NY
tamte
Member
9390 posts
Joined: 7月 2007
オフライン
2021年5月7日 9:56
julianbragagna 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?You can then use Sort SOP to sort prims by your length attribute
And then Blast SOP to keep or delete primitives: 0 1
As those will be the shortest 2
Tomas Slancik CG Supervisor Framestore, NY
2021年5月7日 10:19
tamte You can then use Sort SOP to sort prims by your length attribute And then Blast SOP to keep or delete primitives: 0 1 As those will be the shortest 2That's a great solution! How would I go about applying this on scale, for an arbitrary number of rectangles?
tamte
Member
9390 posts
Joined: 7月 2007
オフライン
2021年5月7日 10:46
easiest would be to run it through For Each Block that iterates per rectangle
Tomas Slancik CG Supervisor Framestore, NY
K Pavan
Member
65 posts
Joined: 11月 2014
オフライン
2021年5月7日 10:49
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 K Pavan - 2021年5月7日 10:59:23
Attachments:
use rest length from convert line.png (575.1 KB)
Houdini Fx Artist (Build)
tamte
Member
9390 posts
Joined: 7月 2007
オフライン
2021年5月7日 16:06
Naga Pavan can sort multiple rectangles with the same blast or delete nodeOnly if no rectangle has larger edge smaller than other rectangle's smaller one
Tomas Slancik CG Supervisor Framestore, NY
2021年5月8日 7:28
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 ));
Attachments:
rect_dir.hipnc (96.9 KB)
2021年5月8日 7:53
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 );
}
Attachments:
rect_dir_pts.hipnc (100.6 KB)
K Pavan
Member
65 posts
Joined: 11月 2014
オフライン
2021年5月9日 1:47
tamte yeah, if rectangles vary in size it fails, I realized sorting with the attribute and deleting 0 1 per connectivity is safer
Konstantin Magnus thank you sharing your sorting methods
Edited by K Pavan - 2021年5月9日 11:11:03
Houdini Fx Artist (Build)