Texture Tiling
Often it is useful to repeat or tile a texture over the surface of a polygon. This was implemented in tile method of the examples that I gave.

               	        .
                        .
                        .
            float denom = 1.0f / w;
            int uval = (int) (u * denom + 0.5f);
            uval = tile(uval, texture.width);
            int vval = (int) (v * denom + 0.5f);
            vval = tile(vval, texture.height);
                        .
                        .
                        .

    private int tile(int val, int size) {
        if (val >= size) {
            do { val -= size; } while (val >= size);
        } else {
            while (val < 0) { val += size; }
        }
    }
Lecture 21 Slide 18 6.837 Fall '98