# Affine transforms - matrix algebra

Martin Desruisseaux martin.desruisseaux at geomatys.fr
Thu Jul 12 13:07:44 PDT 2012

```Le 12/07/12 19:42, Pavel Safrata a écrit :
> Even in this case I don't really like the inconsistency with List
> which allocates new array if the given one is not sufficient. I think
> we either need to choose one of the numbers or do
>
> public double[] toArray(MatrixArrayType type[, double[] a)
>
> where MatrixArrayType is an enum with values MAT_2D, MAT_3D, MAT_Full,
> requesting 6, 12, 16 numbers respectively. How does that sound?

Maybe I lack a little bit of JavaFX knowledge here, but how do we known
for which axes are the 2D-relevant elements? Do the (x,y) plane is
special enough in the JavaFX infrastructure for stating that the Affine
2D elements will never be (x,z) or (y,z)? Otherwise instead of MAT_2D we
could define MAT_XY, MAT_XZ and MAT_YZ.

But maybe there is an other issue: when I look at the matrices
documented in the javadoc of every Transform subclasses except Affine
(and maybe Rotate when the axis of rotation is not Z), I see X and Y
axes that are independent of Z (i.e. the coefficients in the third
column are zero for the first (X) and second (Y) rows). It make sense
for those Transforms to extract a sub-transform for only the (x,y)
plane, because transformations on that plane do not depend on the z value.

But in the Affine class, the mxz and myz coefficients can be anything.
Consequently the transformations on the (x,y) plane may not be
independent of z. If we extract the 2D part of that matrix, we would
need to specify in the javadoc that this two-dimensional transform is
valid only for z=0. For other values of z, the translation terms of the
two-dimensional transform may be different. Do we really want to afford