How can I rotate an image in response to the iPhone's accelerometer?
<p>hai , i use accelerometer to rotate uiimageview through device orientation like  UIInterfaceOrientationLandscapeRight,etc. if i dont use device orientation,(if i put iphone on the table , accelerometer must work in particular angle.The device is in UIInterfaceOrientationPortrait)how can i do it? i rotate the image through center of that imageview ,but i could not understand in which angle it is rotated ,is it rotating based on the center(as origin) ? (<strong>i want graphical representation with origin</strong>)if i want to stop rotation in particular angle,how can i do it?the code : anyone can help me...?</p>

<pre><code>- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration 
{
    rollingX =  (acceleration.x * 0.1) + (rollingX * (1.0 - 0.1));
    rollingY =  (acceleration.y * 0.1) + (rollingY * (1.0 - 0.1));

    float xx = -rollingX; 
    float yy = rollingY;
    float angle = atan2(yy, xx); 
        self.angle += M_PI / 2.0;

    if(self.angle &gt;= -2.25 &amp;&amp; self.angle &lt;= -0.25)
    {
     if(deviceOrientation != UIInterfaceOrientationPortrait)
     {
      deviceOrientation = UIInterfaceOrientationPortrait;
      self.updatingIsEnabled =YES;
      self.foamView.center = CGPointMake(center.x,center.y);
     }

    }
    else if(self.angle &gt;= -1.75  &amp;&amp; self.angle &lt;= 0.75)
    {

     if(deviceOrientation != UIInterfaceOrientationLandscapeRight)
     {
      deviceOrientation = UIInterfaceOrientationLandscapeRight;
      self.updatingIsEnabled =YES;
     }

    }
    else if(self.angle &gt;= 0.75 &amp;&amp; self.angle &lt;= 2.25)
    {
     if(deviceOrientation != UIInterfaceOrientationPortraitUpsideDown)
     {
      deviceOrientation = UIInterfaceOrientationPortraitUpsideDown;
      self.updatingIsEnabled =YES;
      self.foamView.center = CGPointMake(center.x,center.y);
     }
    }
    else if(self.angle &lt;= -2.25 || self.angle &gt;= 2.25)
    {
     if(deviceOrientation != UIInterfaceOrientationLandscapeLeft)
     {
         deviceOrientation = UIInterfaceOrientationLandscapeLeft;
      self.updatingIsEnabled =YES;
      self.foamView.center = CGPointMake(center.x,center.y);

     }
    }
}
</code></pre>
