Frustum intersection code returns bad value
<p>I'm implementing some frustum-related code, and the culling test returns nothing even when there are many visible objects. My mathematical support library does not provide plane support or anything like that, so much of this code is written from scratch with little available testing. If you have any suggestions as to the failure point, please advise. Fortunately there is not much of it, so Little'Wall'o'Code follows:</p>

<pre><code>    class Plane {
    public:
        Plane() {
            r0 = Math::Vector(0,0,0);
            normal = Math::Vector(0,1,0);
        }
        Plane(Math::Vector p1, Math::Vector p2, Math::Vector p3) {
            r0 = p1;
            normal = Math::Cross(p2 - p1, p3 - p1);
        }
        Math::Vector r0;
        Math::Vector normal;
    };
    class Frustum {
    public:
        Frustum(
            const std::array&lt;Math::Vector, 8&gt;&amp; points
            )
        {
            planes[0] = Plane(points[0], points[1], points[2]);
            planes[1] = Plane(points[4], points[5], points[6]);
            planes[2] = Plane(points[0], points[1], points[4]);
            planes[3] = Plane(points[2], points[3], points[6]);
            planes[4] = Plane(points[0], points[2], points[4]);
            planes[5] = Plane(points[1], points[3], points[5]);
        }
        Plane planes[6];
    };

       // http://www.cescg.org/CESCG-2002/DSykoraJJelinek/index.html
       bool Intersects(Math::AABB lhs, const Frustum&amp; rhs) const {
            for(int i = 0; i &lt; 6; i++) {
                Math::Vector pvertex = lhs.TopRightFurthest;
                Math::Vector nvertex = lhs.BottomLeftClosest;
                if (rhs.planes[i].normal.x &lt;= -0.0f) {
                    std::swap(pvertex.x, nvertex.x);
                } 
                if (rhs.planes[i].normal.y &lt;= -0.0f) {
                    std::swap(pvertex.y, nvertex.y);
                }
                if (rhs.planes[i].normal.z &lt;= -0.0f) {
                    std::swap(pvertex.z, nvertex.z);
                }
                if (Math::Dot(nvertex - rhs.planes[i].r0, rhs.planes[i].normal) &gt; 0.0f) {
                    return false;
                }
            }
            return true;
        }
</code></pre>

<p>Also of note is that I'm using a left-handed co-ordinate system, so I inverted the result of the cross product (inside the Cross function).</p>

<p>Edit: As accurately stated, I missed off the vertex indices. They are indexed so that each bit indicates the corner on one axis- that is, 0 indicates the right, the top, and the back, in that order.</p>

<p>Also, I apologize for the generally low quality of the question, but I have no idea what else to add. I've got no compiler warnings or errors, and not enough understanding to make sense of anything I might read in the debugger- this is outside my normal field. And the code compiles with a relatively obvious implementation of <code>Vector</code> and <code>AABB</code>.</p>
