Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm trying to create an application that draws a set of rectangles in a 3d area. I want it to automatically calculate the rectangle that should be drawn first - it's very obvious for a human to know which side must be drawn first, but I have no idea how to actually determine this with mathematics.

This is what it currently does. This example consists of 5 rectangles, all with the same depth and attached to each other: Example

I should somehow calculate which rectangle is the closest to the middle point (0, 0, 0) - I just don't know where to start.

Thanks in advance.

share|improve this question
1  
There's not always a complete solution -- it is possible to arrange three rectangles such that each one passes in front of one of the others. –  Henning Makholm Feb 2 '12 at 15:25
2  
But those situations can be dealt with, by appropriately partitioning the rectangles. A rather elegant (and fairly efficient) solution to the whole problem is to construct a BSP-tree, see en.wikipedia.org/wiki/Binary_space_partitioning –  Martin Wanvik Feb 2 '12 at 15:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.