nag_mv_procustes (g03bcc) computes Procrustes rotations in which an orthogonal rotation is found so that a transformed matrix best matches a target matrix.
First the two sets of points are translated so that their centroids are at the origin to give
and
, i.e., the matrices will have zero column means. Then the rotation of the translated
matrix which minimizes the sum of squared distances between corresponding points in the two sets is found. This is computed from the singular value decomposition of the matrix:
where
and
are orthogonal matrices and
is a diagonal matrix. The matrix of rotations,
, is computed as:
After rotation, a scaling or dilation factor,
, may be estimated by least squares. Thus, the final set of points that best match
is given by:
Before rotation, both sets of points may be normalized to have unit sums of squares or the
matrix may be normalized to have the same sum of squares as the
matrix. After rotation, the results may be translated to the original
centroid.
- 1:
stand – Nag_TransNormInput
On entry: indicates if translation/normalization is required.
- No translation or normalization.
- Translation to the origin.
- Translation to the origin and then to the centroid after rotation.
- Unit normalization.
- Translation and normalization.
- Translation and normalization to scale, then translation to the centroid after rotation.
Constraint:
, , , , or .
- 2:
pscale – Nag_RotationScaleInput
On entry: indicates if least squares scaling is applied after rotation.
- Scaling is to be applied.
- No scaling is applied.
Constraint:
or .
- 3:
n – IntegerInput
On entry: the number of points, .
Constraint:
.
- 4:
m – IntegerInput
On entry: the number of dimensions, .
- 5:
x[] – doubleInput/Output
-
Note: the th element of the matrix is stored in .
On entry: the matrix to be rotated, .
On exit: if
,
x will be unchanged.
If
,
,
or
,
x will be translated to have zero column means.
If
or
,
x will be scaled to have unit sum of squares.
If
,
x will be scaled to have the same sum of squares as
y.
- 6:
tdx – IntegerInput
-
On entry: the stride separating matrix column elements in the array
x.
Constraint:
.
- 7:
y[] – doubleInput/Output
-
Note: the th element of the matrix is stored in .
On entry: the target matrix, .
On exit: if
, then
y will be unchanged.
If
or
, then
y will be translated to have zero column means.
If
or
, then
y will be scaled to have unit sum of squares.
If
or
, then
y will be translated and then after rotation, translated back. The output
y should be the same as the input
y except for rounding errors.
- 8:
tdy – IntegerInput
-
On entry: the stride separating matrix column elements in the arrays
y,
yhat.
Constraint:
.
- 9:
yhat[] – doubleOutput
-
Note: the th element of the matrix is stored in .
On exit: the fitted matrix, .
- 10:
r[] – doubleOutput
-
Note: the th element of the matrix is stored in .
On exit: the matrix of rotations,
, see
Section 9.
- 11:
tdr – IntegerInput
-
On entry: the stride separating matrix column elements in the array
r.
Constraint:
.
- 12:
alpha – double *Output
-
On exit: if
the scaling factor,
; otherwise
alpha is not set.
-
On exit: the residual sum of squares.
- 14:
res[n] – doubleOutput
-
On exit: the residuals, , for .
- 15:
fail – NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
The accuracy of the calculation of the rotation matrix largely depends upon the singular value decomposition. See the
f08 Chapter Introduction for further details.
Not applicable.
Note that if the matrix
is not of full rank, then the matrix of rotations,
, may not be unique even if there is a unique solution in terms of the rotated matrix,
. The matrix
may also include reflections as well as pure rotations, see
Krzanowski (1990).
Three points representing the vertices of a triangle in two dimensions are input. The points are translated and rotated to match the triangle given by (0,0),(1,0),(0,2) and scaling is applied after rotation. The target matrix and fitted matrix are printed along with additional information.