0
$\begingroup$

Alright. So I have a line of points. But not only 1 line. Multiple lines. I say "lines", because the points have all been projected to the same magnitude. So they're all lined up. I used what I learned in this other question to get the lines of points.

Now that they're all lined up, I want to scale them and fit them to their respective edges. The edges are just that: edges of a mesh. The problem is that each point-line is either smaller or larger than its respective edge. And misaligned too. I want them to match up, while still retaining the proportional distance of the points. Like this:

enter image description here

I've thought of a number of half-baked ideas:

  1. The first instinct was to reach for the attribute statistics node. But as far as I'm aware, that thing can only work a single set of attributes at a time. It can't work each group of points individually.

  2. Using the accumulate field node, each point-line can have their points added up, then divided to get the average. On my first test, I fooled myself into believing that actually got the middle point of each point-line. But no, the average is weighted to either one side or the other. I tried a bunch of stuff using this weighted average, but couldn't figure anything out. My guess is that I need the middle point. If only I could just get the minimum and maximum of each point-line. 🤔

  3. Pursuing the middle point(vainly?), I turned to the Points to Curve node. Perhaps turning each point-line to a curve, I can select the middle of the curve, which would also be the middle of the point-line. Or, alternatively, I could just move the curve by selecting the ends, and moving them to the ends of the edges. I couldn't figure out either of these things. The endpoint selection node baffled me. I selected something, but I'm not sure they were the endpoints. If they were , then that means the end points aren't actually at the ends. Which means the Points to Curve node selected middle points as curve ends.

Well in any case. I'm stuck. Any ideas?

$\endgroup$
4
  • 1
    $\begingroup$ Can you produce some .blend file with an example input and desired output for it? What I'm specifically interested in is if you already have some mapping of the point group to an edge, or you want to find the nearest edge? Ad 1: repeat zone. Ad 2: this gives you the average or mean point. By middle point you probably mean the center of the bounding box. Ad 3: you could discover it by converting the points to a curve and sampling at 50% factor. $\endgroup$ Dec 12, 2023 at 23:00
  • $\begingroup$ For a minute, I thought curve sampling at 50% factor was the key. It appears that the resulting points are where they're supposed to be. However, when I subtract from their position, everything goes all lopsided. I suppose I will have to upload a file so you can see what I mean. How do I do that? Where's the file sharing button? $\endgroup$
    – Smeebit
    Dec 13, 2023 at 21:13
  • $\begingroup$ blender.meta.stackexchange.com/q/3050/60486 $\endgroup$ Dec 13, 2023 at 22:08
  • $\begingroup$ Thanks. I added the file to the main post. The geometry node is pretty messy. Sorry about that. I wanted to clean it up, but I kept getting new ideas and trying them out. I thought that perhaps with the curve sample node, I could sample both ends of each curve, and then use that to get their lengths, and then scale the projected points to fit the edges. However, I noticed that the creation of the curves seem to rearrange the points??? 🤔 idk. But using the mix node, it reveals how the points go from their curve position to a completely different position. It's all random. $\endgroup$
    – Smeebit
    Dec 14, 2023 at 4:10

1 Answer 1

0
$\begingroup$

I figured it out. Discovering the minimum and maximum position for every group of points was key. Luckily and thankfully user lukas_t posted a solution for that here. min/max node by lukas_t

With that, I was able to do some sloppy noding to rescale the point groups along the edges. Download the node to see what I mean. Play the timeline to see it visualized. I set up a few "viewer" frames. Connect the viewport viewer on them to see the results. And use the mix node to toggle between normal mesh and projected mesh.

The solution is difficult to explain in words, but I'll try. You start with a few rows of points. How you get those points, is up to you. I get them by projecting one mesh onto another mesh comprised of edges. That yielded a bunch of rows of points. All the rows of points share the magnitude of the nearest edge. So each row is differently angled. Also, each row is essentially assigned their own index, thanks to the sample nearest node grabbing the index of the edges for each respective point.

enter image description here

Now that you have many arbitrary rows of points. You might notice that some rows are longer or shorter than the edges they're projected to. That's what we're here to solve. You use the min/max node I linked. Plug the geometry in there, along with the group index into both group attribute slots. Get the min. Do it a second time to get the max.(You will have to copy and edit the node to get max) If you did it right, then you essentially just selected the endpoints of each row. With those numbers, you can define each row as a sort of an imaginary edge.

enter image description here

From there, all you have to do is get the difference between the distance of the rows and the distance of the edges. And scale the rows to fit the edges. Then, get the difference between the position of the rows(the average of min and max), and the position of the edges, and make the rows take on the edge's position.

If all went well, then the rows of points should perfectly align with the edges. Looking something like this.

enter image description here

$\endgroup$

You must log in to answer this question.

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