konstantin magnus Posted February 5, 2018 Share Posted February 5, 2018 (edited) I put a slightly oblique scanned object into an oriented bounding box and picked two points that are supposed to be straight. Now I am struggling to counter-rotate my mesh according to the bounding box´s orientation. vector scan_orient = normalize( point(0, "P", 0) - point(0, "P", 3) ); vector straight = {0, 0, 1}; matrix3 rot = dihedral(scan_orient, straight); rot = invert(rot); @P *= rot; What am I missing? Edited February 5, 2018 by konstantin magnus Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 5, 2018 Share Posted February 5, 2018 That given orientation is not the optimal to align two vectors. Consider you aligning a geo to same geo rotated by 180 degrees around Y axis using edge looking straight UP. There wouldn't be any transform (vectors already pretty aligned), but orientations are vastly different. dihedral won't help there. I would build a proper basis using at least 3 points here. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted February 5, 2018 Author Share Posted February 5, 2018 (edited) @f1480187 Okay, then let´s assume I took two or three vectors along the edges of my oriented bounding box like this: vector scan_x = normalize( point(0, "P", 0) - point(0, "P", 3) ); vector scan_y = normalize( point(0, "P", 0) - point(0, "P", 1) ); vector scan_z = normalize( point(0, "P", 0) - point(0, "P", 4) ); Whats the most direct way to turn this into a matrix that actually rotates my object back in place? Edited February 5, 2018 by konstantin magnus Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 5, 2018 Share Posted February 5, 2018 @P *= set(scan_x, scan_y, scan_z); The scan_* axes in the snippet above are negative though, I would swap operands. If axes are incorrect, try different combinations of 3-1-4. E.g.: 1-4-3. 1 Quote Link to comment Share on other sites More sharing options...
vinyvince Posted August 7, 2020 Share Posted August 7, 2020 (edited) It's in a way related to my question there https://www.sidefx.com/forum/topic/80359/?page=1#post-345366 Edited August 16, 2021 by vinyvince Quote Link to comment Share on other sites More sharing options...
vinyvince Posted August 7, 2020 Share Posted August 7, 2020 (edited) is there no way to automate the permutations and pick the right one? Edited August 16, 2021 by vinyvince Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.