Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rotation problem



On 11/10/06, Linea Tessile srl <email@hidden> wrote:

               aff = [NSAffineTransform transform];
               [aff translateXBy:-(center.x) yBy:-(center.y)];
               aff1 = [NSAffineTransform transform];
               [aff1 rotateByDegrees:-grado];
               [aff appendTransform:aff1];
               aff2 = [NSAffineTransform transform];
               [aff2 translateXBy: center.x yBy: center.y];
               [aff appendTransform:aff2];

Don't have an answer to your issue (hard to understand what you are finding incorrect...) but I wanted to note that the above code it more difficult then it needs to be. The code could be as simple as the following:

NSAffineTransform* aff = [NSAffineTransform transform];
[aff translateXBy:-(center.x) yBy:-(center.y)];
[aff rotateByDegrees:-grado];
[aff translateXBy:center.x yBy:center.y];

Additionally the following code seem strange to me...

   int xVal,yVal;
   float x,y;
...
    x = PX2MM(((punto->x) - centerX));
    y = PX2MM(((punto->y) - centerY));

    NSString *xs = [NSString stringWithFormat:@"%.f", x];
    NSString *ys = [NSString stringWithFormat:@"%.f", y];

    xVal = [xs intValue];
    yVal = [ys intValue];

You can assign a float variable to an integer variable directly, no need to use an NSString instance in between as you appear to be doing.

xVal = x;
yVal = y;

If you want a particular rounding behavior consider using rintf(),
roundf(), ceilf(), floorf(). You can find more information on those by
using "man rintf", etc. in the Terminal.

I cannot follow what exactly you are attempting to do but I believe
you should be able to transform the whole bezier path instead of
having to do each point (consider -[NSBezierPath
transformUsingAffineTransform:]. Or possibly avoid the use of bezier
path by using -[NSAffineTransform transformPoint:].

-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Rotation problem (From: Linea Tessile srl <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.