Pythagoras animation

When θ = 0 radians, the right angle of the triangle is at the right end of the semicircle. When θ = π radians = 180°, the right angle of the triangle is at the left end of the semicircle. Initially, &theta = π/2 radians = 90°.

Source code in Pythagoras.zip

  1. main.m
  2. Class PythagorasAppDelegate
  3. Class View

Things to try

  1. Instead of moving the animation with a touch, have the animation move by itself.
  2. Everey fraction of a second, change the value of θ and then call the setNeedsDisplay method of the View. To make this happen over and over, create either a CADisplayLink or a NSTimer as shown in this example.