- 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, 2019 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
Follow this Question
Related Questions
create primitive cube a runtime with specific size 3 Answers
Measure a rotating gameobject. 0 Answers
Result of subtracton vectors 1 Answer
How can I calculate the Vector3 b using Vector 3 a pos with an angle? 1 Answer
Angles from Directions 2 Answers