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.