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: a couple of CGContext questions




On Jan 31, 2007, at 3:35 PM, Laurence Harris wrote:


On Jan 31, 2007, at 4:53 PM, Steve Christensen wrote:

On Jan 31, 2007, at 9:11 AM, David Duncan wrote:

On Jan 31, 2007, at 07:58 AM, Mike Kluev wrote:

Wait, what's wrong with CGAffineTransformInvert?

Hadn't thought of that, but same mathematical problems without all the code maintenance ones.


Doing this is akin to trying to draw bicycle spokes by appending a rotation to the context. By the time your done, the floating point errors have accumulated to the point that your spokes don't look correct.

Tho, isn't an inverse just a straight mathematical operation on the actual values in the transform matrix? If so, there's shouldn't be an accumulation error, but I suppose there could be rounding ones where you end up with a 1.000000000000001 or 0.9999999999985 someplace.

Define "straight mathematical operation." If you mean each entry in the inverse matrix is found by operating on one element of the original, then no, it isn't. Google for "inverting a matrix."

The problem with matrix inversion is that some matrices are "ill- conditioned" and roundoff errors become somewhat extreme. You can find an example at <http://math.fullerton.edu/mathews/n2003/ inversematrix/InverseMatrixMod/Links/InverseMatrixMod_lnk_5.html>. In this case, the original matrix is correct to six decimal places. However, the mathematical calculation (done with Mathematica, so it isn't a buggy routine they are using) ends up being off in places by as much as 28259 (an increase in the error by about 10 orders of magnitude). Admittedly, that example was chosen for its extreme deviation, but still, it gives you an idea of what can go wrong.


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

This email sent to email@hidden
References: 
 >Re: a couple of CGContext questions (From: Mike Kluev <email@hidden>)
 >Re: a couple of CGContext questions (From: David Duncan <email@hidden>)
 >Re: a couple of CGContext questions (From: Steve Christensen <email@hidden>)
 >Re: a couple of CGContext questions (From: Laurence Harris <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.