0
votes

Im making an OBB for the stanford bunny for a project. Ive calculated the covarience matrix and found its eigenvectors. The columns of the eigenvector matrix are the components for my rotation matrix, e.g. the first eigenvector column is the first column of my rotation matrix.

To find how much to translate the points to move the OBB back to the centre, I have multiplied a vector containing my centre poitns (xc, yc, zc,1) by the rotation matrix (which I think will give me the new centre point values). I then add the negative of these vales as the translation elements for my transformation matrix.

I then render the bounding box using the max/min points in relation to the x,y,z axis.. Then I do the inverse transformation back. The result is not what I expected.. As you can see, the box is aligned with the new axis, but not in the right way, and it dosent fit around the screwdriver..

enter image description here

Is there something wrong with my theory? Or is the matrix not multiplying correctly.. It seems really far away from the centre if I dont use any translation, but the AOBB calculates perfectly.. Im so confused.

1

1 Answers

0
votes

As commented in your other answer: The centre of the Local coordinate axis (the eigenvector axis origin) is not the centre of your model ((max-min)/2) !! The centre is the mean of the points! {Sum(X), Sum(Y), sum(Z)}/Npoints. They are different points.

As a simple exmaple consider the set of points x=[0 0 0 0 0 0 0 0 10]. The centre of this (called the median in statistics/maths) is 5, but the mean is 1.11111111111111. Do not confuse them! The OBB is always centered in the mean, independently whether your draw the object centered or you just draw it in a random location.

If you are having problems with the OBB, I suggest you read: Oriented Bounding Box is Misshapen and the Wrong Size in OpenGL