On Mon, Jun 2, 2014 at 9:05 AM, Nick Alexander <[email protected]> wrote:
> On 2014-06-02, 4:59 AM, Robert O'Callahan wrote: > >> On Mon, Jun 2, 2014 at 3:19 PM, Rik Cabanier <[email protected]> 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 _______________________________________________ dev-platform mailing list [email protected] https://lists.mozilla.org/listinfo/dev-platform

