Jump to content

Rotate object based on oriented bounding box


konstantin magnus

Recommended Posts

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 by konstantin magnus
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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 by konstantin magnus
Link to comment
Share on other sites

  • 2 years later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...