You are a physics teacher. Can you provide a detailed example of how the law of conservation of energy operates in a real-life scenario, such as in a roller coaster or a pendulum? Additionally, please explain the transformations of energy that occur in this example to help students better understand the concept.