2014-06-02 14:06 GMT-04:00 Benoit Jacob <jacob.benoi...@gmail.com>: > > > > 2014-06-02 13:56 GMT-04:00 Nick Alexander <nalexan...@mozilla.com>: > > On 2014-06-02, 9:59 AM, Rik Cabanier wrote: >> >>> >>> >>> >>> On Mon, Jun 2, 2014 at 9:05 AM, Nick Alexander <nalexan...@mozilla.com >>> <mailto:nalexan...@mozilla.com>> wrote: >>> >>> On 2014-06-02, 4:59 AM, Robert O'Callahan wrote: >>> >>> On Mon, Jun 2, 2014 at 3:19 PM, Rik Cabanier <caban...@gmail.com >>> <mailto:caban...@gmail.com>> wrote: >>> >>> isIdentity() indeed suffers from rounding errors but since >>> it's useful, I'm >>> hesitant to remove it. >>> In our rendering libraries at Adobe, we check if a matrix is >>> *almost* >>> identity. Maybe we can do the same here? >>> >>> >>> One option would be to make "isIdentity" and "is2D" state bits >>> in the >>> object rather than predicates on the matrix coefficients. Then >>> for each >>> matrix operation, we would define how it affects the isIdentity >>> and is2D >>> bits. For example we could say translate(tx, ty, tz)'s result >>> isIdentity if >>> and only if the source matrix isIdentity and tx, ty and tz are >>> all exactly >>> 0.0, and the result is2D if and only if the source matrix is2D >>> and tz is >>> exactly 0.0. >>> >>> With that approach, isIdentity and is2D would be much less >>> sensitive to >>> precision issues. In particular they'd be independent of the >>> precision used >>> to compute and store store matrix elements, which would be >>> helpful I think. >>> >>> >>> I agree that most mathematical ways of determining a matrix (as a >>> rotation, or a translation, etc) come with isIdentity for free; but >>> are most matrices derived from some underlying transformation, or >>> are they given as a list of coefficients? >>> >>> >>> You can do it either way. Here are the constructors: >>> http://dev.w3.org/fxtf/geometry/#dom-dommatrix-dommatrix >>> >>> So you can do: >>> >>> var m = new DOMMatrix(); // identity = true, 2d = true >>> var m = new DOMMatrix("translate(20 20) scale(4 4) skewX"); // >>> identity = depends, 2d = depends >>> var m = new DOMMatrix(otherdommatrix; // identity = inherited, 2d = >>> inherited >>> var m = new DOMMatrix([a b c d e f]); // identity = depends, 2d = >>> true >>> var m = new DOMMatrix([m11 m12... m44]); // identity = depends, 2d = >>> depends >>> >>> If the latter, the isIdentity flag needs to be determined by the >>> constructor, or fed as a parameter. Exactly how does the >>> constructor determine the parameter? Exactly how does the user? >>> >>> >>> The constructor would check the incoming parameters as defined: >>> >>> http://dev.w3.org/fxtf/geometry/#dom-dommatrixreadonly-is2d >>> http://dev.w3.org/fxtf/geometry/#dom-dommatrixreadonly-isidentity >>> >> >> Thanks for providing these references. As an aside -- it worries me that >> these are defined rather differently: is2d says "are equal to 0", while >> isIdentity says "are '0'". Is this a syntactic or a semantic difference? >> >> But, to the point, the idea of "carrying around the isIdentity flag" is >> looking bad, because we either have that A*A.inverse() will never have >> isIdentity() == true; or we promote the idiom that to check for identity, >> one always creates a new DOMMatrix, so that the constructor determines >> isIdentity, and then we query it. This is no better than just having >> isIdentity do the (badly-rounded) check. >> > > The way that propagating an "is identity" flag is better than determining > that from the matrix coefficients, is that it's predictable. People are > going to have matrices that are the result of various arithmetic > operations, that are close to identity but most of the time not exactly > identity. On these matrices, I would like isIdentity() to consistently > return false, instead of returning false 99.99% of the time and then > suddenly accidentally returning true when a little miracle happens and a > matrix happens to be exactly identity. >
...but, to not lose sight of what I really want: I am still not convinced that we should have a isIdentity() method at all, and by default I would prefer no such method to exist. I was only saying the above _if_ we must have a isIdentity method. Benoit > > Benoit > > > >> >> Nick >> >> _______________________________________________ >> dev-platform mailing list >> dev-platform@lists.mozilla.org >> https://lists.mozilla.org/listinfo/dev-platform >> > > _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform