# Shared Vector / Bounds Problem

 0 Hey allSay in Unity you have 2 different sized boxes, 1 large and 1 small. How can I tell if the small box is within the bounds of the large box. I can not use collision detection because I need this process to repeat a couple thousand times quickly and neither raycasting because the normals of the collider are on the opposite side. I am currently using the bounds contains function however when rotating the large box object the bounds expands to cover the diagonal angle of the rotation.Any suggestions? Many thanks to all those that can help. Winston more ▼ asked Jan 17 '12 at 01:16 PM Winston 3 ● 4 ● 4 ● 7 "How can I tell if the small box is within the bounds of the large box.".......You mean within the box .. right? i.e. you DO NOT want to know if it is within the Bounding Box, you want to know if it is ACTUALLY within the BOX. Correct?PS it's sometimes best to turn the object inside out in cases like this, then you can use ray casting. Jan 17 '12 at 01:42 PM Fattie Yes. You are correct. Do you know of any simple functions that exist and will achieve this? Jan 17 '12 at 05:09 PM Winston Hi Winston.(1) I understand what you're after now.(2) Unfortunately (like many problems in real-time gaming) it's not easy by any means!(3) Note that essentially you are trying to check if all 8 corner points are contained in the other box.(4) In answer to your question, there is NO simple, everyday function or API available that will instantly check this for you - you have to develop the maths for your situation. To begin with this sort of field, you can look in to the classic text Real-Time Collision Detection - Christer Ericson and also Eric Lengyel 'Game Mathematics'.(5) Your question is confusing because in both the title and the 2e sentence you say "the bounds of..." suggesting you are after the "Bounding Box" ("OBB") solution -- which is a totally and completely different problem set. You should click edit. Better you should probably just delete this question altogether and post a new question saying simply "does anyone have a good solution on hand for box within box calculations" and then note that you are looking for "not OBB, the actual boxes in space". You could also look on for example stack overflow and gamedev(6) FTR I had a glance around and couldn't find any ready-to-roll solutions!Hope this info helps you ! Jan 18 '12 at 07:33 AM Fattie add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

1 answer: sort voted first
 0 Basically what you're trying to achieve is a OBB to OBB collision detection. There should be lots of examples out there but here's a good table to help you start:http://www.realtimerendering.com/intersections.html more ▼ answered Jan 17 '12 at 01:33 PM Rod Green 2.9k ● 2 ● 9 ● 42 For the record Rod, it turns out he's explicitly NOT looking for an OBB solution - he wants to check the actual box against the actual box. Jan 18 '12 at 07:34 AM Fattie add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Topics:

x195
x181
x179
x94
x8

asked: Jan 17 '12 at 01:16 PM

Seen: 577 times

Last Updated: Jan 18 '12 at 07:34 AM