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

Re: quick comments on Matrix

From: Dirk Schulze <dschulze@adobe.com>
Date: Sat, 16 Mar 2013 08:33:45 -0700
To: Gregg Tavares <gman@google.com>
CC: "public-fx@w3.org" <public-fx@w3.org>
Message-ID: <46734134-A860-4E4C-8E28-371A1B204ED8@adobe.com>
Hi Gregg,

On Mar 15, 2013, at 10:57 PM, Gregg Tavares <gman@google.com> wrote:

> Sorry if I'm late to the party. If there's already a huge discussion of this just point me to it.
> 
> But, some questions
> 
> 
> Why m11,m12,m13,m14  etc instead of m00, m01, m02, m03?
> 
> If I'm doing arrays in JavaScript they start at 0. It would be nice to be able to do this
> 
> for (var i = 0; i < 4; ++i) {
>   for (var j = 0; j < 4; ++j) {
>      someMatrix['m'+i+j] = someArray[i][j];
>   }
> }
> 
> If they start at m11 that becomes much less pleasant. Yes I know there are constructors etc that take various types of arrays. My only point is it seems more consistent if the indices or implied indices match.

Matrix is not an array to set the values like for an array. m11 to m44 are attributes and it seems to make sense to have more natural names used in science. But I can see your point. It should be considered that two implementations already use this naming schema, even if they are not fully compatible to this spec [1][2]. It may be the expectation of authors that the specified interface has the same naming schema.

> 
> 
> Why combine 2x3 and 4x4 Matrixes?
> 
> It seems like it makes the implementation slower (have to check if I should be doing 2x3 or 4x4 math) and while behind the scenes you could have 2 different classes that begs the question, why not just expose them separately? 

One main reason of this spec is sharing matrices between different aspects of the web platform: Canvas, SVG, CSS Transforms/CSSOM and WebGL. CSS and SVG use 2D and 3D transformations which can switch between each other on the fly. It seems far more painful for users to check that all the time and transform the matrices between each other all the time.

> 
> 
> How about lookAt, perspective, ortho and frustum?
> 
> Those are used in nearly every 3D app.
> 
> 
> How about on top of transformPoint also transformDirection, transformVector?
> 
> All of those are useful and commonly needed.
> 
> transformPoint =  (m * p) / p.w
> transformVector = (m * p)
> transformDirection = (m * p) but ignores the last row of m

The dictionary is called Point and is very generic. It leaves it up to the author how to use it. Point as well as Vector transformations use the same operations anyway. I would rather keep it that way instead of introducing more functions that just add more confusion. I take suggestions for a better name if that helps authors.

> 
> transformPoint and transformVector is needed as they're common for doing mouse to 3D calculations.
> 
> Why Point instead of Vector?
> 
> I don't want to bikeshed here but in my limited circle a Point doesn't have a W. A Point represents a place in 2D or 3D space. Mathematically you can't add 2 points but you can add 2 vectors. Subtracting 2 points gives you a vector. Adding a vector to a point transforms a point. Adding 2 vectors gives another vector. That might just be my experience and not connected to any reality but I've seen the distinction in libraries I've used. It's also related the suggestion for transformPoint vs transformVector.
> 
> How about add, subtract, scale, distance, normalize, length, lengthSquared, dot, and cross on Point?

It is up to your imagination how you want to use the dictionary. The specification doesn't limit you here in any way. The focus of this specification is transformation matrix representation and not the full spectrum of linear algebra.

> 
> Just asking. If all point is is x,y,z,w and no functionality them might as well get rid of it and just pass Float32Array(4) everywhere.
> 
> 
> 

This is maybe the difference between the WebGL world and other areas of the web platform. A WebGL author may prefer Float32Array. A dictionary seems still more generic and better served for the whole web platform. But I do not have strong feelings about that. Keep in mind that there are discussions about a DOMPoint for pointer events. This dictionary is hopefully a way to share the interests for pointer events as well.

Greetings,
Dirk

[1] http://msdn.microsoft.com/en-us/library/windows/apps/hh453593.aspx
[2] http://developer.apple.com/library/safari/#documentation/AudioVideo/Reference/WebKitCSSMatrixClassReference/WebKitCSSMatrix/WebKitCSSMatrix.html
Received on Saturday, 16 March 2013 15:34:15 GMT

This archive was generated by hypermail 2.3.1 : Saturday, 16 March 2013 15:34:16 GMT