# The meaning of size variable in ComputeOBB of OBBTree

**URL:** https://discourse.vtk.org/t/the-meaning-of-size-variable-in-computeobb-of-obbtree/1313
**Category:** Support
**Created:** [July 9, 2019, 6:38pm UTC](https://discourse.vtk.org/t/the-meaning-of-size-variable-in-computeobb-of-obbtree/1313 "2019-07-09T18:38:34Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Robert\_Sawko](https://discourse.vtk.org/user_avatar/discourse.vtk.org/robert_sawko/32/5048_2.png) [@Robert\_Sawko](https://discourse.vtk.org/u/Robert_Sawko)
#### Post date: [July 9, 2019, 6:38pm UTC](https://discourse.vtk.org/t/the-meaning-of-size-variable-in-computeobb-of-obbtree/1313/1 "2019-07-09T18:38:34Z")

</div>

Hi,

Just a quick question regarding oriented bounding boxes. I am struggling to interpret the meaning of `size` variable in `ComputeOBB` function. Below I am attaching a minimal example which creates a sphere, an ellipsoid and a rotated ellipsoid. When I look at the values of `min`, `mid` and `max` then I can clearly see the lengths of my bounding boxes. For `size` the docs say:

> sorted list of relative “sizes” of axes for comparison purposes.

which sounds a bit mysterious to me, but the word “relative” is clearly key to my lack of understanding. Could anyone elaborate please? Thanks.

Example:

```auto
#include <vtkNew.h>
#include <vtkOBBTree.h>
#include <vtkPoints.h>
#include <vtkSphereSource.h>
#include <vtkParametricEllipsoid.h>
#include <vtkTransform.h>
#include <vtkParametricFunctionSource.h>
#include <vtkTransformPolyDataFilter.h>

class OBBFunctor {
private:
  vtkNew<vtkOBBTree> OBB;
public:
  OBBFunctor() {};

  void operator() (vtkSmartPointer<vtkPolyData> data) const
  {
    double corner[3] = {0.0, 0.0 ,0.0};
    double max[3] = {0.0, 0.0 ,0.0};
    double mid[3] = {0.0, 0.0, 0.0};
    double min[3] = {0.0, 0.0, 0.0};
    double size[3] = {0.0, 0.0, 0.0};

    OBB->ComputeOBB(data, corner, max, mid, min, size);

    std::cout << "Origin:\t" << corner[0] << " " << corner[1] << " " << corner[2] << std::endl
              << "Max:\t" << max[0] << " " << max[1] << " " << max[2] << std::endl
              << "Mid:\t" << mid[0] << " " << mid[1] << " " << mid[2] << std::endl
              << "Min:\t" << min[0] << " " << min[1] << " " << min[2] << std::endl
              << "Size:\t" << size[0] << " " << size[1] << " " << size[2] << std::endl;

  }
};

int main ( int argc, char *argv[] )
{
    vtkNew<vtkSphereSource> sphere;
    sphere->SetCenter(0.0, 0.0, 0.0);
    sphere->SetRadius(1.0);
    sphere->SetThetaResolution(128);
    sphere->SetPhiResolution(128);
    sphere->Update();

    vtkNew<vtkParametricEllipsoid> ellipsoid; 
    ellipsoid->SetXRadius(1.0);
    ellipsoid->SetYRadius(2.0);
    ellipsoid->SetZRadius(3.0);

    vtkNew<vtkParametricFunctionSource> parametricFunctionSource;
    parametricFunctionSource->SetUResolution(64);
    parametricFunctionSource->SetVResolution(64);
    parametricFunctionSource->SetWResolution(64);
    parametricFunctionSource->SetScalarModeToNone();
    parametricFunctionSource->GenerateTextureCoordinatesOff();
    parametricFunctionSource->SetParametricFunction(ellipsoid);
    parametricFunctionSource->Update();

    vtkNew<vtkTransform> transform;
    transform->RotateX(30.0);

    vtkNew<vtkTransformPolyDataFilter> transformed_ellipsoid;
    transformed_ellipsoid->SetTransform(transform);
    transformed_ellipsoid->SetInputConnection(parametricFunctionSource->GetOutputPort());
    transformed_ellipsoid->Update();

    OBBFunctor print_obb;
    std::cout << "A sphere." << std::endl;
    print_obb(sphere->GetOutput());
    std::cout << "The original ellipsoid." << std::endl;
    print_obb(parametricFunctionSource->GetOutput());
    std::cout << "The transformed ellipsoid!" << std::endl;
    print_obb(transformed_ellipsoid->GetOutput());
    return EXIT_SUCCESS;
}

```

Output:

```auto
A sphere.
Origin: 0.978708 -1.02027 -1
Max: 2.89524e-14 3.00906e-14 2
Mid: -1.99898 0.0415672 2.83122e-14
Min: 0.0415672 1.99898 -3.0677e-14
Size: 0.333273 0.333179 0.333179
The original ellipsoid.
Origin: -0.998446 -1.99876 3
Max: 2.83922e-17 7.14057e-12 -6
Mid: -9.39699e-17 3.99751 4.75742e-12
Min: 1.99814 4.69704e-17 9.45524e-18
Size: 2.50416 1.22338 0.414305
The transformed ellipsoid!
Origin: -0.998446 -3.23097 1.5987
Max: 9.20086e-17 3 -5.19615
Mid: -2.14944e-17 3.46195 1.99876
Min: 1.99814 -6.016e-18 3.19078e-17
Size: 2.50416 1.22338 0.414305

```

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [July 10, 2019, 3:14pm UTC](https://discourse.vtk.org/t/the-meaning-of-size-variable-in-computeobb-of-obbtree/1313/2 "2019-07-10T15:14:40Z")

</div>

Hello, it seems to me that those values can be used for sorting in STL containers, to tell which is bigger or smaller, to compute aspect ratio, etc. You can not use them to compute actual measurementes, only for applications that only require relative values.

---

<div class="post-metadata">

### Author: ![lorensen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lorensen/32/20_2.png) [@lorensen](https://discourse.vtk.org/u/lorensen)
#### Post date: [July 11, 2019, 9:23pm UTC](https://discourse.vtk.org/t/the-meaning-of-size-variable-in-computeobb-of-obbtree/1313/3 "2019-07-11T21:23:01Z")

</div>

The sizes are the eigenvalues of the eigenvectors of the OBB. Eigenvalues are invariant under a linear transformation.

---

<div class="post-metadata">

### Author: ![Robert\_Sawko](https://discourse.vtk.org/user_avatar/discourse.vtk.org/robert_sawko/32/5048_2.png) [@Robert\_Sawko](https://discourse.vtk.org/u/Robert_Sawko)
#### Post date: [March 25, 2021, 1:09pm UTC](https://discourse.vtk.org/t/the-meaning-of-size-variable-in-computeobb-of-obbtree/1313/4 "2021-03-25T13:09:47Z")

</div>

@lorensen and @Paolo_Lampitella thanks for your replies. Yes, it’s clear to me that this is some way related to eigenvalues, but I don’t understand what is it it relative to? I’ve set the radii to be 1, 2, 3. I thought it may relative to bounding box diameter, but the numbers don’t add up.

---

<div class="post-metadata">

### Author: ![timeanddoctor](https://discourse.vtk.org/user_avatar/discourse.vtk.org/timeanddoctor/32/2847_2.png) [@timeanddoctor](https://discourse.vtk.org/u/timeanddoctor)
#### Post date: [January 28, 2022, 2:52pm UTC](https://discourse.vtk.org/t/the-meaning-of-size-variable-in-computeobb-of-obbtree/1313/5 "2022-01-28T14:52:53Z")

</div>

I am confused by the corner, coord\_max, coord\_mid, coord\_min, sizes…

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 29, 2022, 12:27pm UTC](https://discourse.vtk.org/t/the-meaning-of-size-variable-in-computeobb-of-obbtree/1313/6 "2022-01-29T12:27:59Z")

</div>

Of which class?
