Make line length match width of object directly underneath

   1718   4   1
User Avatar
Member
99 posts
Joined: April 2014
Offline
I have a line hovering above another object (in this example, it's just a grid, but it's more irregularly shaped in what I need). I would like it so that the line length matches the width of the object directly underneath, without reorienting the line, and preferably without actually snapping it to the new point (in y).

Ideally, if I could extract a bbox D_XMIN (/MAX) (or a getbbox min.x), but only at the point in z where the line is, then I could just translate the points to that location. I'm sure this is super-simple, but I'm not quite sure how to go about it.

A ray SOP gets me in the ballpark, but presents some problems, as in the pics.

Thanks!
Edited by bentway23 - Oct. 21, 2019 13:35:00

Attachments:
overhead.PNG (157.7 KB)
with ray.PNG (314.6 KB)
hangsOnCorner.PNG (174.8 KB)
lineray.hiplc (65.0 KB)

User Avatar
Member
21 posts
Joined: Sept. 2018
Offline
I have no idea how you'd intersect a point with a 2d shape when they're on the same plane. You could extrude the shape and intersect the two points toward the centroid of the line.

vector dir = getbbox_center(0)-@P;

vector hit_pos, hit_uv;

int hit_prim = intersect(1, @P, dir*100, hit_pos, hit_uv);


@P = hit_pos;

If your shape is curved you have to ensure the extrusion is “up” straight toward your line not along its normal or it'll widen/shrink/deform. Alternatively you could resample the line, ray/intersect every point straight down, delete any that don't hit anything (are outside the bounds of the shape), and finally delete every point in the middle of the line.

Edit: Oh and this needs more work if your points could potentially be within the bounds of the shape, probably by reversing the direction of the intersect.

Hip because words are hard.
Edited by vandoornjerry - Oct. 22, 2019 04:25:22

Attachments:
rrd.hiplc (115.0 KB)

User Avatar
Member
40 posts
Joined: Aug. 2018
Offline
For a quick and potentially dirty -depending on your exact goals(*)- but simple solution, you can try this, cf picture.

Intersection Analysis node will complain (yellow asterix), but it will still do the work.

Then Delete node (not just ‘Blast’), working on ‘Bounding Volume’ only, with the kind of simple setup shown.

Then Add node with just the classic ‘By Group’ tab enabled to redraw a similarly simple 2points line, as your original one (apparently…?).



(*) : this option does not resize your original line, but redraw one…
Edited by Herve - Oct. 22, 2019 06:10:56

Attachments:
test.jpg (150.7 KB)

User Avatar
Member
40 posts
Joined: Aug. 2018
Offline
also, when you say that your line is “hovering” over the grid/second object, I assume on the relatively same flat XZ plane. if it's not (like at some Y distance from the grid), but still flat, you'll need to adjust the intersecAnalysis proximity tolerance, keeping as close as possible, plus a little marging (I'll clarify if you want to try this option).

If your line is not ‘flat’ on the same XY plane as your grid, then you'll need a few more adjustments, obviously. Again, I'd kinda “cheat” by flatting it just before streaming it to IntersectAnalysis, potentially giving back its true vector to the redrawn line after the Add.
Edited by Herve - Oct. 22, 2019 06:28:43
User Avatar
Member
99 posts
Joined: April 2014
Offline
Thanks for the pointers! Actually, I did not want the line to intersect, just to change its length accordingly. Also, the reference shape was a lumpy riverbed, not just a flat plane, so intersection was possible. What I ended up doing (based on some other pointers from odForce–and not unlike some of the pointers above) was to resample the hell out of my line, ray it down onto the riverbed, use intersect analysis to create points, used an add to create a line from those points, sorted the points, and then used a wrangle to kill everything but the first and last points. That didn't keep the line above the riverbed/reference shape, but at that point it was easy enough to throw a transform there and lift it back up.

There are some points above that are new to me, so I'll dig in now. Thanks again!
  • Quick Links