Writing games generally involves a fair bit of trigonometry. I never really liked it at school but it turns out I did remember one thing: a little phrase to aid one’s memory of equations for a right-angled triangle. In my current project I need to work out a coordinate position based on an angle and a distance – which relate to the angle and hypotenuse of said triangle. Now I realise this isn’t rocket science, but because I’m so generous I’m gonna share my function for returning the coordinates (from 0,0 origin) to a point at an angle and distance:

CGPoint translateAngleDistance(float angle, float distance)

{

CGPoint returnVal;

returnVal.x = cos(angle) * distance;

returnVal.y = sin(angle) * distance;

return returnVal;

}