-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
* adds section on matrix transformations
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -740,6 +740,43 @@ operation is requested that requires the inverse of a transformation that can no | |
implementations MAY estimate an inverse, or MAY output a warning that the requested operation is unsupported. | ||
|
||
|
||
#### Matrix transformations | ||
|
||
Two transformation types ([affine](#affine) and [rotation](#rotation)) are parametrized by matrices. Matrices are applied to | ||
column vectors that represent points in the input coordinate system. The first (last) axis in a coordinate system is the top | ||
(bottom) entry in the column vector. Matrices may be stored either as row-major flat (one-dimensional) arrays or two-dimensional | ||
arrays, either in json or stored in a zarr array. When stored as a 2D zarr array, the first dimension indexes rows, and the | ||
second dimension indexes columns (e.g., an array of `"shape":[3,4]` has 3 rows and 4 columns). When stored as a 2D json array, | ||
the inner array contains rows (e.g. `[[1,2], [3,4], [5,6]]` has 3 rows and 2 columns). | ||
|
||
<div class=example> | ||
|
||
For matrix transformations, points in the coordinate system: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
LucaMarconato
|
||
|
||
``` | ||
{ "name" : "in", "axes" : [{"name" : "z"}, {"name" : "y"}, {"name":"x"}] }, | ||
``` | ||
|
||
are represented as column vectors: | ||
|
||
``` | ||
[z] | ||
[y] | ||
[x] | ||
``` | ||
|
||
As a result, transforming the point `[z,y,x]=[1,2,3]` with the matrix `[[0,1,0],[-1,0,0],[0,0,-1]]` | ||
results in the point [2,-1,3] because it is computed with the matrix-vector multiplication: | ||
|
||
``` | ||
[ 0 1 0] [1] [ 2] | ||
[-1 0 0] [2] = [-1] | ||
[ 0 0 -1] [3] [-3] | ||
``` | ||
|
||
</div> | ||
|
||
|
||
### Transformation types | ||
|
||
Input and output dimensionality may be determined by the value of the "input" and "output" fields, respectively. If the value | ||
|
@@ -888,15 +925,15 @@ y = 2 * j | |
|
||
#### <a name="affine">affine</a> | ||
|
||
`affine` transformations from N-dimensional inputs to M-dimensional outputs are represented at `(N)x(M+1)` | ||
`affine`s are [matrix transformations](#matrix-transformations) from N-dimensional inputs to M-dimensional outputs are represented at `(N)x(M+1)` | ||
matrices in homogeneous coordinates. This transformation type is invertible when `N` equals `M`. | ||
The matrix may be stored as a 2D array (inner arrays represent the rows of the matrix) or as a 1D array (row-major). | ||
|
||
<dl> | ||
<dt><strong>path</strong></dt> | ||
<dd> The path to a zarr-array containing the affine parameters. | ||
The array at this path MUST be 1D or 2D. If 1D, its length MUST be `N*(M+1)`. | ||
If 2D its size must be `N x (M+1)`.</dd> | ||
If 2D its shape must be `N x (M+1)`.</dd> | ||
<dt><strong>affine</strong></dt> | ||
<dd> The affine parameters stored in JSON. The matrix may be stored as a row-major flat array of numbers that MUST be | ||
length `N*(M+1)`, or as 2D nested array where the outer array MUST be length `N` and the inner arrays MUST be length `M+1`.</dd> | ||
This comment has been minimized.
Sorry, something went wrong.
LucaMarconato
|
||
|
@@ -949,20 +986,17 @@ The matrix may be stored as a 2D array (inner arrays represent the rows of the m | |
|
||
#### <a name="rotation">rotation</a> | ||
|
||
`rotation` transformations are special cases of affine transformations. | ||
When possible, a rotation transformation SHOULD be defined rather than | ||
its equivalent affine. Input and output dimensionality (N) MUST be | ||
identical and greater than 1. Rotations are stored as `NxN` matrices, | ||
see below, and MUST have determinant equal to one, with orthonormal rows | ||
and columns. The matrix may be stored as a 2D array (inner arrays represent | ||
the rows of the matrix) or as a 1D array (row-major). `rotation` transformations | ||
are invertible. | ||
`affine`s are [matrix transformations](#matrix-transformations) that are special cases of affine transformations. When possible, a rotation | ||
This comment has been minimized.
Sorry, something went wrong. |
||
transformation SHOULD be preferred to its equivalent affine. Input and output dimensionality (N) MUST be identical and greater | ||
than 1. Rotations are stored as `NxN` matrices, see below, and MUST have determinant equal to one, with orthonormal rows and | ||
columns. The matrix may be stored as a 2D array (inner arrays represent the rows of the matrix) or as a 1D array (row-major). | ||
`rotation` transformations are invertible. | ||
|
||
<dl> | ||
<dt><strong>path</strong></dt> | ||
<dd> The path to an array containing the affine parameters. | ||
The array at this path MUST be 1D or 2D. If 1D, its length MUST be `N*N`, | ||
This comment has been minimized.
Sorry, something went wrong.
LucaMarconato
|
||
if 2D its size must be `N x N`.</dd> | ||
if 2D its shape must be `N x N`.</dd> | ||
<dt><strong>rotation</strong></dt> | ||
<dd> The parameters stored in JSON. The matrix may be stored as a row-major flat array of numbers that MUST be | ||
length `N*N`, or as 2D nested array where the outer array MUST be length `N` and the inner arrays MUST be length `N`.</dd> | ||
|
This looks great, but I would add an example for affine transformations to be more complete. In particular I would clarify that: