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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to