The main triangle projection in matrix spaces and its applications