• 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
Re: Obtaining rotation from CTM
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Obtaining rotation from CTM


  • Subject: Re: Obtaining rotation from CTM
  • From: Nathan Vander Wilt <email@hidden>
  • Date: Thu, 21 Aug 2008 09:01:20 -0700


On Aug 21, 2008, at 6:56 AM, Tilman Bender wrote:

Hi there,

Is it possible to obtain the angle of rotation from a tranformation- matrix created with CGAffineTransfrom?


If you haven't applied any other transforms to your CGAffineTransform, you could determine the rotation (in radians) via:

double rotationInRadians = acos(theTransform.a); // if the transform ONLY rotates around the origin

My linear algebra is fairly rusty, so I may be forgetting some things, but I don't think it's practical to determine in the general case when you've also scaled and translated back and forth besides just rotating. A few cases will not affect the result above, but in most cases used in drawing, the above will probably not work. But I'm not sure why you'd need to do this in the first place, see below...


Background:
I am building a simple kitchen-timer app, that should work like the ones in your mom's kitchen:
You set the time by touching a control and rotating it. Now I would like to obtain the current
angle of my clock.


I know how to use and create CGAffineTransform stuff, but I am not really familiar with the extraction of specific information from
such a matrix.


My question is: why do you need to get the rotation out of an affine transform?

Somewhere in your code you've determined an angle from a move event, I would assume. It would make a lot more sense to keep track of the current angle, and only convert that to a CGAffineTransform in your drawing code, than to for some reason store a CGAffineTransform and try to extract the angle from that.

hope this helps,
-natevw
_______________________________________________

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


References: 
 >Obtaining rotation from CTM (From: Tilman Bender <email@hidden>)

  • Prev by Date: How to pause and resume an animation that uses a transform (CATransform3DMakeScale)?
  • Next by Date: Re: Sending a message to super's super (tab keyDown in NSTextView)
  • Previous by thread: Re: Obtaining rotation from CTM
  • Next by thread: CALayer retain count
  • Index(es):
    • Date
    • Thread