Solve This Math Problem

I’m a bit sleep deprived right now. I’m going to the zoo this weekend and I need to push my sleep schedule forward, so I’ve been up all night and a good bit of day so far. For some reason I decided to work on my TextWorld project during this time.

I need some math for this. I’m sure I’ll figure it out myself eventually if I have to, but it occured to me that I have some very nerdy friends who might be able to do this for me. Or at least figure out the math, I’ll probably have to alter it to work in Flash.

Anyways I need to figure out if a particular rectangular polyhedron defined by x, y, z in meters will fit inside another rectangular polyhedron defined by x, y, z, in any orientation.

The TextWorld Simulation considers everything to be a six sided rectangular polyhedron internally, and I need to be able to tell if a particular object will fit in a particular space. It wouldn’t be too bad if I just had to figure out if it would fit while the two were flat, but I need to know if it would fit in an angle. Like, a two by four might not fit in a room unless it’s bent so that the tips are in the far corners of the room.

So, how do I figure out if a thing fits in a particular space?

Tagged , ,

2 thoughts on “Solve This Math Problem

  1. Sebkha says:

    Doing this precisely seems pretty difficult, since I’m gathering you want to search all possible orientations for one that fits. Can you make do with an approximation that wouldn’t care about orientation, such as a bounding sphere?

    • Relee says:

      Yeah I’m starting to think it might be too complex for the platforms I’m aiming at, even if I figure out the math. Especially if I have a lot of stuff doing motions like this constantly all over the world.

      If I’m going to do it like this I want it to be exact, but I’m not sure I want to do it like this anymore. An alternative I’m considering is using something like a scale variable. It could be something like a series of tags like “Large” “Small” “Tiny” “Fine” like they use in D&D, or I could use an actual number.

      Because the space could already have objects in it, it becomes vastly more complex than just finding if one box fits in another in any orientation.

      Anyways the point of it was to keep large objects from being stuffed into space that they won’t fit into. I also wanted to include inventories for mobiles, which would be a box intersected with a lot of other smaller boxes, and it’s quickly becoming ridiculous. With a physics simulation it would be much simpler but I’m just making a text world.

      So, I think I’ll simplify it all.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.