how does one go from

[Im(cos theta + i sin theta)^3]/[Re(cos theta + i sin theta)^3]

to

=[3cos^2 theta sin theta - sin^3 theta]/[cos^3 theta - 3 cos theta sin^2 theta]

I heard it's something to do with some triangle but I don't understand the details. Help would be much appreciated