gabyx / ApproxMVBB

Fast algorithms to compute an approximation of the minimal volume oriented bounding box of a point cloud in 3D.
Mozilla Public License 2.0
441 stars 93 forks source link

missing expandZeroExtent functionality (OOBB) #21

Closed hamidhomapour closed 6 years ago

hamidhomapour commented 6 years ago

I want to use OOBB to compute good approximation or exact computation of the minimum volume bounding box of a point set. After computation, I have the box but it is somehow scaled! and based on the ReadME, it seems I should use oobb.expandZeroExtent to get a proper box. Unfortunately, I couldn't find that functionality. Am I right?

gabyx commented 6 years ago

The two functions you are looking for are in OOBB.hpp:

void expandToMinExtentRelative(PREC p = 0.1, PREC defaultExtent = 0.1, PREC eps = 1e-10);
void expandToMinExtentAbsolute(PREC minExtent);
gabyx commented 6 years ago

What do you mean with scaled? Can you attach a picture? Does the output make sense?

hamidhomapour commented 6 years ago

chair2

The above image is just drawing based on m_minPoint and m_maxPoint, but for the following images I use "oobb.m_q_KI oobb.m_minPoint" and "oobb.m_q_KI oobb.m_maxPoint" to draw the box.

chair

As you can see the legs are not inside the box.

chair3

In this image clearly, the box is large.

And also my code to compute the box is this:

` ApproxMVBB::Matrix3Dyn points(3, thePart->mesh.number_of_vertices());

int i = 0;

for (VertexIndex v: thePart->mesh.vertices()) { Point p = thePart->mesh.point(v); points(i, 0) = p.x(); points(i, 1) = p.y(); points(i, 2) = p.z(); }

theOOBB = ApproxMVBB::approximateMVBB(points,0.000001,500,5,0,5); `

gabyx commented 6 years ago

The computation of the points in the world frame like you describe is correct: "oobb.m_q_KI oobb.m_minPoint" and "oobb.m_q_KI oobb.m_maxPoint"

You are using 500 sample points of your original point cloud (see your call approximateMVBB) You may make the OOBB contain all points by iterating over all points after you computed the OOBB: https://github.com/gabyx/ApproxMVBB/blob/db2ec171aa2a464a24182be553f124d3564f076c/example/approxMVBB/src/main.cpp#L47

The functions

void expandToMinExtentRelative(PREC p = 0.1, PREC defaultExtent = 0.1, PREC eps = 1e-10);
void expandToMinExtentAbsolute(PREC minExtent);

are only meaning full when you encounter boxes with individual really small extents (say points in a plane)