Re: Rotate NSString... I give up :( [SOLVED]
Re: Rotate NSString... I give up :( [SOLVED]
- Subject: Re: Rotate NSString... I give up :( [SOLVED]
- From: Nathan Vander Wilt <email@hidden>
- Date: Wed, 6 Aug 2008 17:13:53 -0700
On Aug 6, 2008, at 2:08 PM, Vitaly Ovchinnikov wrote:
Yes, you right, but I expected what I need to move text to the zero
point, rotate it and move it back. But NSAffineTransform works quite
the contrary and requires to move the zero point to the text and then
back. That was a big surprise for me.
Remember that affine transforms are of the form v' = Mv. So if you
want to transform a vector by a matrix:
v' = Mv
...and then by another matrix:
v'' = Nv'
But if you want to do it all in one step, you would do:
v'' = NMv
See how it's not MNv but NMv? What this means is that you must
concatenate your transformation matrix in the opposite order of how
you want it to transform your points. I'd agree this is surprising, I
myself spent a long time one day trying to "debug" NSAffineTransform
just on account of forgetting this relationship.
hope this helps,
-natevw
On Thu, Aug 7, 2008 at 12:55 AM, Kyle Sluder
<email@hidden> wrote:
On Wed, Aug 6, 2008 at 4:37 PM, Vitaly Ovchinnikov
<email@hidden> wrote:
Yes, he right. I've just tested it and it works fine.
I though that -translateXBy:yBy: will move my object, but it moved
pivot point... This is hard, especially with revesed OY axis ;)
Well, it all happens in one transformation matrix. If I recall
matrix
math correctly (probably not), rotation is a linear transformation,
but translation isn't, so in order to get rotation to work right the
pivot point must be the origin. Since you want to rotate the object
around its center, you need to translate it twice. This is all
chained together in one transformation matrix, so when the
multiplication's done the net result is one matrix that does all
three
operations.
Anyone, please feel free to correct me, I would very much appreciate
any clarification. :D
--Kyle Sluder
_______________________________________________
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
_______________________________________________
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