I'm trying to make sure the long side of this object is always aligned with the x-axis, no matter what direction the source object is facing. I figured the max vector would probably be aligned somewhere towards the end of the long edge, so I thought I could use the dot product to check if that's aligned with $(1,0,0)$ and if it isn't, see what the angle is, and just sort of "un-rotate" it by that much. But it isn't working for some reason. I've been working on this for a while, and at this point, I'm out of ideas, so if anybody could tell me where I went wrong, or a better way to approach this, I'd be eternally grateful.
-
1$\begingroup$ If the orientation of the object is random, there is no easy way to find "the longest axis". The classical way to solve this problem is to use Principal Component Analysis (PCA). I recommend to start to read Mr A answer here. Let me know if you need more support. I could adapt the tailored GN graph posted here. $\endgroup$– StefLAncienCommented Dec 30, 2023 at 8:42
-
$\begingroup$ Oh my. This might be over my head for now. Thanks for the input! I'll see if I can understand those posts, and if not, maybe just stick with the less flexible bounding box solution I had before. $\endgroup$– ArcomadeCommented Dec 30, 2023 at 18:30
1 Answer
I'm not sure if this is what you're looking for, but in your case the object gets the rotation via the transform properties.
Therefore, it would be possible to invert exactly this rotation and thus reset the rotation to the original orientation.
In your case, the object then points exactly upwards. By adding any other rotation, you can align the object to the X-axis, regardless of how the transformation of the original object is changed.
Something like this: