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

RE: Matrix4x4 proposal

From: Timm Drevensek <Timm.Drevensek@igd.fraunhofer.de>
Date: Tue, 24 Jan 2012 15:58:02 +0100
To: <dino@apple.com>, <igor.oliveira@openbossa.org>, <public-fx@w3.org>, "'public-d3d mlist'" <public-declarative3d@w3.org>
Message-ID: <001301ccdaa8$9232deb0$b6989c10$@igd.fraunhofer.de>

We were discussing about your implementation proposal and there came up some question about the constructors and the underlying data type of a matrix class:
Related to the Khronos TypedArray specifications: http://www.khronos.org/registry/typedarray/specs/latest/

Would it be an idea to design the Matrix class in a way that:
- It works internally on ArrayBuffer as the underlying data container.
- The Matrix class itself derives from an ArrayBufferView like TypedArrays does.

- Extendable by any existing libraries that are acting on TypedArrays (glMatrix) without any copy of data from and to the Matrix class (just provide a pointer to the underlying TypedArray container)
- Possibility for a performing way for creating arrays of matrices: By multiple views into a single container (see subarray() & constructor(buffer, byteOffset, length) @ TypedArray spec)
- Same interfaces for 32 and 64 bit Matrices
- No overhead for copy to the GL context

- If you act on a ArrayBufferView you cannot create a 3x3 matrix "view" into a container, holding a 4x4 matrix (like subarray() of TypedArrays) due the offset after each row break.
For work around this issue, the Matrix could act on an extended 2 dimensional ArrayBufferView...with holds information on size and offset for the 2. dimension...or a construct like the step_iterator, available in the boost gil library: (see http://stlab.adobe.com/gil/html/gildesignguide.html#StepIteratorDG) 

Timm Drevensek

> [
>     // Creates an identity matrix
>     Constructor(),
>     // Creates a new matrix from the value passed in (which is CSS transform string with
>     // matrix() or matrix3d() - not other functions).
>     Constructor(in DOMString string),
>     // Creates a new matrix from the Float32Array value passed in (length of 6 for a 2d matrix, or 16 for a 4x4 matrix).
>     Constructor(in Float32array array),
>     // Creates a new matrix identical to the passed matrix.
>     Constructor(in Matrix4x4 matrix),
>     // Creates a new matrix from the array of 6 or 16 values passed in
>     Constructor(in sequence<float> array) ]


>     // Copy the matrix elements into a Float32Array
>     // Throws an exception if the input is invalid (e.g. wrong length, etc).
>     void copyIntoFloat32Array(inout Float32Array array) raises (DOMException);
>     // return a Float32Array (length 16) with the values [m11, m12, ...]
>     Float32Array toFloat32Array();
Received on Tuesday, 24 January 2012 14:59:11 UTC

This archive was generated by hypermail 2.3.1 : Monday, 22 June 2015 03:33:46 UTC