- Home /

# max size of a cube at irregular angles

Hello, please forgive my lack of terminology. I feel like this should be a simple thing, but I can't find the words to find the proper answer.

How can I get the size of a cube at an irregular angle using bounds (collider) and a direction(vector3).

I have a bounding box, which can give me XYZ size, but I want the max size if the bounds are approached at a particular direction.

As per my crappy MS paint example. I have cube with bounding box, and a random direction, so how would I measure that artfully drawn purple line.

Thanks.

**Answer** by Bunny83
·
Feb 26 at 05:19 AM

It's not really clear what you want to know exactly. However the Bound is an AABB (Axis Aligned Bounding Box). So it's always aligned with either the world space (in case of Collider.bounds or Renderer.bounds) or aligned with the local space of the object (in case of Mesh.bounds). To calculate an arbitrary bounding box you would need to iterate through all vertices of the object and transform them into your desired space / orientation and calculate the bounding box there manually.

It's not clear on what information you want to base your calculations on. In your screen shot you've drawn your purple line in screen space of the editor camera. So you should try to be more precise about your usecase and what you need this for.

I want to measure a object. I want to be able to measure it at any angle. I have a bounding box and a direction. I know the standard width, height and depth of my bounding box. But what if I want to know how long it is at a different angle? If I stab a spear, at a random angle, through a box, how much of the spear is inside the box?

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Dimensions of a Cube 2 Answers

Angles from Directions 2 Answers

How do i make a flowing 90 degree turn? 1 Answer

Measure a rotating gameobject. 0 Answers

Find angle between two gameobjects? 1 Answer