Using matrix to draw triangles