Implement triangle intersection code