follow target with a camera

Im trying to implement a third person camera from above and behind player. The camera must follow player of course, and rotates with player whe it faces any direction. My problem is that I still cant grasp the maths behind the process, so Im looking for some working code as simple as posible to use it as base to build my engine. Can somebody give me a help with this?

If the camera is going to be always behind the player, you haven’t got to move it. Just do that for every frame:

1- Clear screen.
2- Draw the player.
3- Rotate and translate the world to reflect the player’s position.
4- Draw the world.