• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Coordinate Rotation at a Point
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Coordinate Rotation at a Point


  • Subject: Coordinate Rotation at a Point
  • From: Gordon Apple <email@hidden>
  • Date: Mon, 05 Nov 2007 23:33:50 -0600

    Although I found references to rotating a Bezier path, searching for
rotating coordinates at a point wasn't fruitful.  In my case, I wanted to
rotate a shape in place about its center, including shading and/or content.
I believe the following is about as simple as you can get and can be used to
rotate about any point.

@implementation  NSAffineTransform (RTPTransformAdditions)

- (void)rotate:(float)angle atPoint:(NSPoint)point
{
    [self rotateByDegrees:angle];
   NSAffineTransform* pointXfrm = [NSAffineTransform transform];
    [pointXfrm rotateByDegrees:-angle];    //    Needed to get original
point in rotated coordinates.
    NSPoint oldPoint = [pointXfrm transformPoint:point];
    float x = oldPoint.x - point.x;
    float y = oldPoint.y - point.y;
    [self translateXBy:x yBy:y];    //    Done in the rotated coordinates.
}

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Coordinate Rotation at a Point
      • From: Ron Fleckner <email@hidden>
  • Prev by Date: IKSlideShow problem with NSImage
  • Next by Date: Re: Coordinate Rotation at a Point
  • Previous by thread: IKSlideShow problem with NSImage
  • Next by thread: Re: Coordinate Rotation at a Point
  • Index(es):
    • Date
    • Thread