1
$\begingroup$

Like "Distribute Points on Faces" to place this seeds on the strawberry mesh. Instead I wanna use the "Mesh To Points" node for even distribution on the strawberry mesh. For that I can capture the Normal Attribute, and in Doc for Distr. Points the Rotation Euler can also be built from the Normal with the "Rotate Euler" Node to get the right rotation. But how exactly?

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

So you have two vectors. You have the Normals of each vertex, and you have the axis of your Seed object you want to align to those normals—let's say it's the Z axis $[0,0,1]$. To align two 3D vectors in space, you can find a third axis that's perpendicular to both (Cross Product), then use that axis to rotate one of them in reverse, equal to the angle between them. You can use Dot Product to calculate the angle. Here's the formula ($n$: Normal, $z$: Z-axis):

$$cos(angle) = { dotproduct(n, z) \over length(n) \cdot length(z) } $$

Normals are already normalized, as in, their length is $1$, and we'll use a $1$-length Z value ourselves, so the divider part in that formula goes away. Which means we can get the angle simply with:

$$arccosine(dotproduct(n,z))$$

Here's an annotated setup to demonstrate, hopefully it's clear: enter image description here

Maybe that's good to know. However, we already have a node that does all that for us: Align Euler to Vector. You can still use Rotate Euler afterwards, using the Normals as the rotation axis, to orient them randomly, for example:

enter image description here

$\endgroup$
4
  • $\begingroup$ Wow, thanks for this explanation. Obviously I don't know enough in mathematic anymore to solve this. But this is a good explanation, now I probably can use often Dot Product and Cross Product with this in Geometry Nodes. $\endgroup$
    – Gordon1fm
    Feb 1, 2023 at 11:37
  • $\begingroup$ So already really nice explanation. But I tested it, and the rotation is still not aligned as in the Rotation Output of "Distribute Points on Faces" Node. I can program a lil bit and saw into this Node code: and its any vector to quaternion method with normal, obj -Z and obj +Y and then quaternion to euler, (because of the gimbal lock in Euler rotations). Maybe you can see the mathematic behind it, and make it similar. $\endgroup$
    – Gordon1fm
    Feb 1, 2023 at 21:38
  • $\begingroup$ Or then somehow rotate Euler with Normal, so every seed points downwards, to -Z $\endgroup$
    – Gordon1fm
    Feb 1, 2023 at 21:47
  • $\begingroup$ @Gordon1fm Remember the sentence from the manual you yourself had quoted: "Keep in mind that the Z axis of the result rotation will be arbitrary, since the mesh normal used to create the rotation does not have enough information to set all three rotation axes." It's not about quaternions, I think. Not to mention Distribute node uses the Face Corners to place the instances, while with Mesh to Points you're using the vertices, so the normals are already different. Is what you really want for them to all point "downwards/upwards"? $\endgroup$
    – Kuboå
    Feb 1, 2023 at 21:50

You must log in to answer this question.

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