Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3311522
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:53:12+00:00 2026-05-17T21:53:12+00:00

I am trying to rotate an image. This I am succeeding in doing. The

  • 0

I am trying to rotate an image. This I am succeeding in doing. The problem is that when I am clicking down and dragging slightly, the image rotates completely to reach the point where I have clicked and then rotates slowly as I drag the image clockwise. I am concerned to why it is rotating completely to the place that I am dragging. I want the dragging to start from the position it is found and NOT to rotate to the place my finger is down on and then starts from there.

This is my code:

–

    (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {   
    }

    -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
        NSSet *allTouches = [event allTouches];

        int len = [allTouches count]-1;

        UITouch *touch =[[allTouches allObjects] objectAtIndex:len];
        CGPoint location = [touch locationInView:[self superview]];
        float theAngle = atan2( location.y-self.center.y, location.x-self.center.x );

        totalRadians = theAngle;

        [self rotateImage:theAngle];

    }

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
}

-(void) rotateImage:(float)angleRadians{

    self.transform = CGAffineTransformMakeRotation(angleRadians);
    CATransform3D rotatedTransform = self.layer.transform;
    self.layer.transform = rotatedTransform;    
}

Am I doing anything wrong?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:53:13+00:00Added an answer on May 17, 2026 at 9:53 pm

    Instead of creating the transformation from the angle that your getting from the touch, try incrementing totalRadians by its difference from the new angle, and then create the transform from that.

    -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
            NSSet *allTouches = [event allTouches];
    
            int len = [allTouches count]-1;
    
            UITouch *touch =[[allTouches allObjects] objectAtIndex:len];
            CGPoint location = [touch locationInView:[self superview]];
            float theAngle = atan2( location.y-self.center.y, location.x-self.center.x );
    
            totalRadians += fabs(theAngle - totalRadians);
            totalRadians = fmod(totalRadians, 2*M_PI);
    
            [self rotateImage:totalRadians];
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to rotate an image in OpenCV. I've used this code that
I'm trying to make a tool that transforms image (rotate, resize, later crop). This
Using this code I'm trying to rotate an image. Image rotated but with a
I'm trying to rotate an image, but it's getting slightly messed up when I'm
I am trying to rotate image. I am using this Java code: BufferedImage oldImage
I am trying to rotate an image using jquery that will rotate on multiple
I am trying to model the layout that is displayed in this image .
I am trying to rotate image that is placed partly on the screen using
I'm trying to rotate an image about the bottom right corner. To do this
I have an image that I am trying to rotate 30 degrees and move

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.