title: Trouble making object move in a circle
body: <p>I'm new to animation in android. I'm working with a tutorial I have found on youtube. The app draws a picture of a ball on a canvas and then moves diagonally. I'd like to make the ball move in a circle. I've found some information about the basic math of circular motion but I'm having trouble implementing it. Could someone look at my code and tell me what I'm doing wrong. Thanks.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class DrawingTheBall extends View {
  
  Bitmap bball; 
  int x,y;
  
  public DrawingTheBall(Context context) {
      super(context);
      // TODO Auto-generated constructor stub
      bball = BitmapFactory.decodeResource(getResources(), R.drawable.blueball);
      x = 0;
      y = 0;
  }
  
  @Override
  public void onDraw(Canvas canvas){
      super.onDraw(canvas);
  
      Rect ourRect = new Rect();
      ourRect.set(0, 0, canvas.getWidth(), canvas.getHeight()/2);
      float a = 10;
      float b = 10;
      float r = 20;
      double theta = 0;
      theta = Math.toRadians(45);
  
      Paint blue = new Paint();
      blue.setColor(Color.BLUE);
      blue.setStyle(Paint.Style.FILL);
  
      canvas.drawRect(ourRect, blue);
  
      if(x &lt; canvas.getWidth()){
          //x += 10;
          x = (int) (a +r*Math.cos(theta));
      }else{
          x = 0;
      }
      if(y &lt; canvas.getHeight()){
          //y += 10;
          y = (int) (b +r*Math.sin(theta));
      }else{
          y = 0;
      }
      Paint p = new Paint();
      canvas.drawBitmap(bball, x, y, p);
      invalidate();
  }
  </code></pre>
  
  <p>}</p>