W3C home > Mailing lists > Public > public-fx@w3.org > January to March 2013

Re: comments on Matrix

From: Rik Cabanier <cabanier@gmail.com>
Date: Thu, 21 Mar 2013 11:33:36 -0700
Message-ID: <CAGN7qDC9_heah_EUmPfmkK5xmWpppFixVDOYUFJ_V69R3rwvjA@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Benoit Jacob <jacob.benoit.1@gmail.com>, "public-fx@w3.org" <public-fx@w3.org>
On Thu, Mar 21, 2013 at 11:26 AM, Tab Atkins Jr. <jackalmage@gmail.com>wrote:

> On Thu, Mar 21, 2013 at 11:21 AM, Rik Cabanier <cabanier@gmail.com> wrote:
> > Direct2D also refuses to do the inversion:
> >
> http://msdn.microsoft.com/en-us/library/windows/desktop/dd372277(v=vs.85).aspx
> > Given that all the libraries refuse to invert and all of Adobe's graphics
> > applications (such as Photoshop and Illustrator) do the same under the
> hood
> > with no ill effects, let's not do this by default.
> >
> > If you feel very strongly, we can provide another call that never
> throws. We
> > would have to change the IDL of the matrix interface though since it
> could
> > now contain unrestricted doubles.
>
> This is very much the wrong decision.  Throwing is a *very* disruptive
> thing in Javascript.  You don't just "catch it and abort", because
> there's rarely a reason to assume that any given calculation will
> fail.  Do you wrap try/catches around every single matrix inversion in
> your code?  Of course not.
>
> Web APIs should *not* be throwing except in actual exceptional error
> situations.  When possible, they should fail gracefully.  Anything
> else is just asking for pages to die for no good reason.  The fact
> that this can throw or not depending on the precise algorithm/number
> implementation underneath makes it even worse.
>
> If you'd like to track whether or not the inversion failed, so authors
> don't have to check the matrix themselves, add a flag.
>
> I'll formally object to an exception being thrown here.
>

SVG matrix throws an exception and since this is a drop-in replacement,
Matrix needs to throw one too :-(

Most libraries seem to return a boolean to say that a inversion failed
which seems better. I *believe* adding an exception to JS also forces the
creation of an exception object every time which is expensive.
Why don't we add another Inverse:

boolean Inverse(Matrix);


We could also move to unrestricted doubles so we can populate the matrix
with NaN or Inf if needed.
Received on Thursday, 21 March 2013 18:34:03 GMT

This archive was generated by hypermail 2.3.1 : Thursday, 21 March 2013 18:34:03 GMT