Hello, I have mesh and its max edge vector. I need to align this to the main X or Y axis, could anybody help? thanks
Hi filanek,
first of all, your setup won’t give you the longest edge reliably. It will just return the vector with the biggest values.
Here’s an example with a point on (0.1, 0.1, 0.1) and another point on (-10.0, -10.0, -10.0):
Clearly, the vector of the second point is way longer than the first one but the Max output of the Attribute Statistic node will still return (0.1, 0.1, 0.1) as the result because a value of +0.1 is bigger than a value of -10.0. You might find the answers from this question on BSE helpful.
Back to your original question → If you manage to get the longest edge vector, you could try to align the X-axis to it and then just invert the resulting rotation:
Zebr4, could you help me once more please? Now I am almost aligned, but still need to rotate some parts 90 degrees. As the objects I need to solve are flat, I am comparing to X or Y if my longest vector DOT is ±0.5 and want use this info as switch to align to X or Y. Of course there is something wrong… Thanks!
If i understand you correctly, you want to check if the angle between the X-axis and your vector is greater or smaller than 45°, right?
If so, the problem lies in the Comparison node:
The Dot Product returns the cosine of the two vectors. Therefore:
cos(45°) =~ 0.785
acos(0.5) = 60°
Does that solve your problem?
Thanks, It seems to be slightly better, but still very unreliable, probably this approach is wrong, have to figure this out…
Hi Zebr4, now all seems working well, no dot product necessary, you first advice worked well in all situations, there was just a big mess in my nodes. thanks again.