• 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: Group CGAffineTransform Animations?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Group CGAffineTransform Animations?


  • Subject: Re: Group CGAffineTransform Animations?
  • From: Erik Buck <email@hidden>
  • Date: Wed, 17 Jun 2009 13:40:51 -0700 (PDT)

Only a little bit of math is neccessary to use affine transforms.  A lot of math is needed for general 3D programming, but let's ignore that for now.
 
My third grader was tought about associative and communitive math operstions.  Some matrix operations are associative and some are communitive.  That's why the order of operations matters.
 
To scale and rotate a square without moving the center of the square, do the following:
A) translate to the center of the square making that position the new origin for scaling and rotation.
B) Scale the coordinate system.
C) Rotate the coordinate system
D) Translate back to the original origin
F) Draw the square
 
It's not so hard typed in web-mail:
 
CGAffineTransform TransformToScaleAndRotateAboutCenterOfSquare(NSRect  someSquare)
{
   CGAffineTransform transform = CGAffineTransformMakeTranslation(
      NSMidX(someSquare), NSMidY(someSquare));
   transform = CGAffineTransformScale (transform, 2.0f, 2.0f);
   transform = CGAffineTransformRotate(transform, DEGS_TO_RADS(90));
   transform = CGAffineTransformTranslate(transform, -NSMidX(someSquare), -NSMidY(someSquare));
 
   return transform;
}
 
 
_______________________________________________

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: Group CGAffineTransform Animations?
      • From: WT <email@hidden>
  • Prev by Date: Re: Group CGAffineTransform Animations?
  • Next by Date: Re: Group CGAffineTransform Animations?
  • Previous by thread: Re: Group CGAffineTransform Animations?
  • Next by thread: Re: Group CGAffineTransform Animations?
  • Index(es):
    • Date
    • Thread