Bounding box against rectangle

What is the difference between a bounding box and a rectangle?

This question is specifically about Unity 3D Bounds and Rect , but I'm interested in a general answer.

In particular:

  • Which is better in performance?
  • Is the bounding box just a three-dimensional rectangle?
  • When do I prefer one by one?
  • Are they interchangeable, and if so, why does Unity 3D have separate classes for them?
  • Any other knowledge you can give will be greatly appreciated!
+5
source share
2 answers

Which is better in performance?

Unnecessary. They are the same in 2D, and in 3D they have different meanings / uses.

Is the bounding box just a three-dimensional rectangle?

There is no such thing as a 3D rectangle. You mean the box. A bounding box is a box that is large enough to span all colliding parts of an entity / model.

When should I choose one by one?

Wrong, see first paragraph.

Are they interchangeable, and if so, why does Unity 3D have separate classes for them?

Again, 2D vs 3D.

Any other knowledge you can give will be greatly appreciated!

Limitations exist to improve collision detection efficiency. If the two bounding rectangles of the body do not intersect, there is no need for further processing of any of their colliders or in 2D, which performs an ideal test of intersection with a pixel. The bounding blocks allow the collision detection algorithm to quickly discard any guaranteed non-colliding bodies.

+4
source

The main difference is 2d vs 3d.

You cannot define the border of a 3D object with a 2d rectangle.

In theory, you can use Bounds instead of Recto (by setting one axis to 0), but not Rect instead of Bounds. There will be little performance loss as Bounds will require more data.

Abbot Flatland is a classic overview of the interactions between 2d and 3d space.

+2
source

Source: https://habr.com/ru/post/1206982/


All Articles