• 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: Coordinate conversions in CALayer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coordinate conversions in CALayer


  • Subject: Re: Coordinate conversions in CALayer
  • From: James Montgomerie <email@hidden>
  • Date: Thu, 24 Jan 2013 09:26:20 +0000

On 24 Jan 2013, at 08:19, Graham Cox <email@hidden> wrote:

> I've made some progress, in that I managed to make the two code snippets work the same, by changing this line:
>
> 	tfm = CGAffineTransformConcat( tfm, layer.transform );
>
> to this:
>
> 	tfm = CGAffineTransformConcat( layer.transform, tfm );
>
> I do appreciate that matrix concatenation isn't commutative, but it's still not clear to me why it needs to be this way round when the equivalent line when manipulating the CTM is:
>
> CGContextConcatCTM( ctx, layer.transform );
>
> This suggests that internally, this call passes the CTM as the second parameter, not the first. If so, then the documentation could do well to spell that out, since matrix order is so important. If not, then my understanding is still off, which does not surprise me.

I looked this up again, because it's hit me in the past - it feels unintuitive to me half the times I use it too, but it is actually spelled out in the docs:

------

CGContextConcatCTM (http://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CGContext/Reference/reference.html):

Transforms the user coordinate system in a context using a specified matrix.

void CGContextConcatCTM(CGContextRef c, CGAffineTransform transform);

...

Discussion: When you call the function CGContextConcatCTM, it concatenates (that is, it combines) two matrices, by multiplying them together. The order in which matrices are concatenated is important, as the operations are not commutative. When you call CGContextConcatCTM, the resulting CTM in the context is: CTMnew = transform * CTMcontext.

------

CGAffineTransformConcat (http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGAffineTransform/Reference/reference.html):

Returns an affine transformation matrix constructed by combining two existing affine transforms.

CGAffineTransform CGAffineTransformConcat(CGAffineTransform t1, CGAffineTransform t2);

...

Return Value: A new affine transformation matrix. That is, t’ = t1*t2.

------

Jamie.


_______________________________________________

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: 
 >Coordinate conversions in CALayer (From: Graham Cox <email@hidden>)
 >Re: Coordinate conversions in CALayer (From: Andy Lee <email@hidden>)
 >Re: Coordinate conversions in CALayer (From: Graham Cox <email@hidden>)
 >Re: Coordinate conversions in CALayer (From: Graham Cox <email@hidden>)
 >Re: Coordinate conversions in CALayer (From: Quincey Morris <email@hidden>)
 >Re: Coordinate conversions in CALayer (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Hover button and tracking area questions
  • Next by Date: Re: Hover button and tracking area questions
  • Previous by thread: Re: Coordinate conversions in CALayer
  • Next by thread: Re: Coordinate conversions in CALayer
  • Index(es):
    • Date
    • Thread