2
$\begingroup$

Simple Geometry node displacement

Hello! I'm working on a Geometry Nodes procedural project, and I would like to improve something within the system: as simplified in the picture shown, I'm starting with a cube with some subdivision that is being displaced by some random textures. now, after the displacement, I want to "pick" the vertices that are the most far from each other, the most "opposite" vertices we could say, they could be anywhere in space after being displaced, and I want blender to "draw" a straight line between them , to use as an axis, and then I want to allign this line, this axis, with a world axis, say the world Y axis.
Basically, I want the object to be re-alligned with the world on the "longer" side is being created after being displaced.
Any ideas?

EDIT: AWESOME ANSWER by Robin Betts, that's great it works! the only issue now is that the line that is being created in order to allign the geometry is now perfectly in the center of the world axis, so the midpoint of the line become our new origin for the whole geometry, so the origin of the geometry is i little off... the result is awesome, just what I needed, but would there be a way to then "Set Origin" to the object volume, and offset the position, so that the center of volume is always alligned at world origin, while the line that we calculated remains parallel to choosen world axis?

Origin issue

$\endgroup$
0

1 Answer 1

4
$\begingroup$

Maybe a proper mathematician can come along and prove or refute this strategy. All I can say at the moment is that it's passing quite extreme tests, so far.

  • Take the convex hull. The extreme points must be in it, somewhere.
  • Find the furthest point from the mean of all points. (Pm)
  • From the remainder, find the furthest from Pm (Pm')
  • As requested, create a line between Pm and Pm' and transform the geometry such that its origin lies on the center of the line, and the line is oriented along an axis.

enter image description here

Above, makes a selection of the point(s) that are farthest from the mean position. Yes. We are hoping there's only one. But the possibility of a 'tie' is implicit in your question, not a problem with the solution.

Then the position of the point at that distance is derived:

enter image description here

A similar procedure follows for getting the furthest position from this one. A line is drawn between them. The whole is aligned as follows, where the incoming vectors are the ends of the line:

enter image description here

This is the result, on a not-very-random object:

enter image description here

Unless/until I think of a proof, I half expect this to get broken. Have a go, and see if you can.

$\endgroup$
3
  • $\begingroup$ Very interesting! I assumed a much more elaborate solution, but this looks really creative. ...Convex Hull, again :D $\endgroup$
    – quellenform
    Jun 28, 2022 at 16:15
  • $\begingroup$ @quellenform The Convex Hull is only to cut down the number of tests? Maybe that should be the median for the first test, not the mean (feels better, somehow) .. still trying to work out a proof, or break it... $\endgroup$
    – Robin Betts
    Jun 28, 2022 at 16:24
  • $\begingroup$ Hi, @Jacopo .. thanks for the tick! I will improve this a bit.. a Field at Index (0) to get hold of extreme positions would behave better in the event of tied-distances than the Mean used here, I think. $\endgroup$
    – Robin Betts
    Jun 29, 2022 at 10:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .