<p>I compute bounding box of a mesh:</p>

<pre class="lang-cpp prettyprint-override"><code>(xMin, xMax)
(yMin, yMax)
(zMin, zMax)
</code></pre>

<p>To get the bounding box, I need to go through all the mesh points and compute the min/max in X, Y and Z directions.</p>

<p><a href="https://i.sstatic.net/aFosU.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/aFosU.png" alt="Mesh not rotated"></a></p>

<p>Then I rotate the mesh. To get the bounding box for the rotated mesh, I need to go through all the mesh points again.</p>

<p><a href="https://i.sstatic.net/PrIUB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/PrIUB.png" alt="Mesh rotated"></a></p>

<p>Is there a method to avoid going through all the mesh points <strong>again</strong> when object is rotated?</p>

CC BY-SA 4.0
2020-01-04T14:06:41.290Z
Yes. Find the diameter of the mesh, and use it for a bounding sphere (or a bounding box containing that sphere). That way the box will be loose, but you won't need to recompute it. The other option is to work with a lower LoD version of the mesh (that bounds it) and recompute the AABB for it.
lightxbulb
CC BY-SA 4.0
2020-01-05T05:39:40.433Z
@lightxbulb Thanks for your hint =) specially a version of mesh with lower LoD looks like a good idea :)
Megidd
CC BY-SA 4.0
2020-01-06T02:44:08.707Z
@user3405291 be careful that your lower LoD version actually enclose the object. eg. The typical polygonal approximation to a circle can, if oriented just right, yield a box which leaves out parts of the circle.
Olivier
CC BY-SA 4.0
2020-01-06T05:36:58.030Z
@Olivier I didn't quite grasp what you meant. Can you provide a link to an example? Thanks :)
Megidd
CC BY-SA 4.0
2020-01-07T12:54:31.440Z
@user3405291 Draw a circle (high detail model). Draw an axis aligned square with its four vertices on the circle (very low detail model). The bounding box of the square is the square itself. But it leaves out parts of the circle. The same can happen with a more general and 3D model, causing subtle errors with the bounds. Those may not matter to your specific application though.
Olivier
CC BY-SA 4.0
2020-01-07T13:26:28.827Z
@Olivier Now I got it =)
Megidd
<mesh>
Bounding box of a rotating mesh
Megidd
# Bounding box of a rotating mesh

(Asked by: username_0 on 2020-01-04)

I compute bounding box of a mesh:

```cpp
(xMin, xMax)
(yMin, yMax)
(zMin, zMax)

```

To get the bounding box, I need to go through all the mesh points and compute the min/max in X, Y and Z directions.

[![Mesh not rotated](https://i.sstatic.net/aFosU.png)](https://i.sstatic.net/aFosU.png)

Then I rotate the mesh. To get the bounding box for the rotated mesh, I need to go through all the mesh points again.

[![Mesh rotated](https://i.sstatic.net/PrIUB.png)](https://i.sstatic.net/PrIUB.png)

Is there a method to avoid going through all the mesh points **again** when object is rotated?

**Tags:** mesh

> **Comments:**
> **username_1**: Yes. Find the diameter of the mesh, and use it for a bounding sphere (or a bounding box containing that sphere). That way the box will be loose, but you won't need to recompute it. The other option is to work with a lower LoD version of the mesh (that bounds it) and recompute the AABB for it.  
> **username_0**: @username_1 Thanks for your hint =) specially a version of mesh with lower LoD looks like a good idea :)  
> **username_2**: @user3405291 be careful that your lower LoD version actually enclose the object. eg. The typical polygonal approximation to a circle can, if oriented just right, yield a box which leaves out parts of the circle.  
> **username_0**: @username_2 I didn't quite grasp what you meant. Can you provide a link to an example? Thanks :)  
> **username_2**: @user3405291 Draw a circle (high detail model). Draw an axis aligned square with its four vertices on the circle (very low detail model). The bounding box of the square is the square itself. But it leaves out parts of the circle. The same can happen with a more general and 3D model, causing subtle errors with the bounds. Those may not matter to your specific application though.  
> **username_0**: @username_2 Now I got it =)  

---

## 0 answers

