Beispiel #1
0
Bounds Bounds::GetTransformedBounds(const Matrix &m) const
{
    Bounds newBounds;
    BOOL bInitialized=0;
    for(int i=0; i<8; i++)
    {
        Vect p = GetPoint(i);
        p.TransformPoint(m);

        if(!bInitialized)
        {
            newBounds.Max = newBounds.Min = p;
            bInitialized = 1;
        }
        else
        {
            if(p.x < newBounds.Min.x)
                newBounds.Min.x = p.x;
            else if(p.x > newBounds.Max.x)
                newBounds.Max.x = p.x;

            if(p.y < newBounds.Min.y)
                newBounds.Min.y = p.y;
            else if(p.y > newBounds.Max.y)
                newBounds.Max.y = p.y;

            if(p.z < newBounds.Min.z)
                newBounds.Min.z = p.z;
            else if(p.z > newBounds.Max.z)
                newBounds.Max.z = p.z;
        }
    }

    return newBounds;
}