D06 Chapter Contents
D06 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentD06DAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

D06DAF is a utility which performs an affine transformation of a given mesh.

## 2  Specification

 SUBROUTINE D06DAF ( NV, NEDGE, NELT, NTRANS, ITYPE, TRANS, COORI, EDGEI, CONNI, COORO, EDGEO, CONNO, ITRACE, RWORK, LRWORK, IFAIL)
 INTEGER NV, NEDGE, NELT, NTRANS, ITYPE(NTRANS), EDGEI(3,NEDGE), CONNI(3,NELT), EDGEO(3,NEDGE), CONNO(3,NELT), ITRACE, LRWORK, IFAIL REAL (KIND=nag_wp) TRANS(6,NTRANS), COORI(2,NV), COORO(2,NV), RWORK(LRWORK)

## 3  Description

D06DAF generates a mesh (coordinates, triangle/vertex connectivities and edge/vertex connectivities) resulting from an affine transformation of a given mesh. This transformation is of the form $Y=A×X+B$, where
• $Y$, $X$ and $B$ are in ${ℝ}^{2}$, and
• $A$ is a real $2$ by $2$ matrix.
Such a transformation includes a translation, a rotation, a scale reduction or increase, a symmetric transformation with respect to a user-supplied line, a user-supplied analytic transformation, or a composition of several transformations.
This routine is partly derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

None.

## 5  Parameters

1:     NV – INTEGERInput
On entry: the total number of vertices in the input mesh.
Constraint: ${\mathbf{NV}}\ge 3$.
2:     NEDGE – INTEGERInput
On entry: the number of the boundary or interface edges in the input mesh.
Constraint: ${\mathbf{NEDGE}}\ge 1$.
3:     NELT – INTEGERInput
On entry: the number of triangles in the input mesh.
Constraint: ${\mathbf{NELT}}\le 2×{\mathbf{NV}}-1$.
4:     NTRANS – INTEGERInput
On entry: the number of transformations of the input mesh.
Constraint: ${\mathbf{NTRANS}}\ge 1$.
5:     ITYPE(NTRANS) – INTEGER arrayInput
On entry: ${\mathbf{ITYPE}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{NTRANS}}$, indicates the type of each transformation as follows:
${\mathbf{ITYPE}}\left(i\right)=0$
Identity transformation.
${\mathbf{ITYPE}}\left(i\right)=1$
Translation.
${\mathbf{ITYPE}}\left(i\right)=2$
Symmetric transformation with respect to a user-supplied line.
${\mathbf{ITYPE}}\left(i\right)=3$
Rotation.
${\mathbf{ITYPE}}\left(i\right)=4$
Scaling.
${\mathbf{ITYPE}}\left(i\right)=10$
User-supplied analytic transformation.
Note that the transformations are applied in the order described in ITYPE.
Constraint: ${\mathbf{ITYPE}}\left(\mathit{i}\right)=0$, $1$, $2$, $3$, $4$ or $10$, for $\mathit{i}=1,2,\dots ,{\mathbf{NTRANS}}$.
6:     TRANS($6$,NTRANS) – REAL (KIND=nag_wp) arrayInput
On entry: the parameters for each transformation. For $i=1,2,\dots ,{\mathbf{NTRANS}}$, ${\mathbf{TRANS}}\left(1,i\right)$ to ${\mathbf{TRANS}}\left(6,i\right)$ contain the parameters of the $i$th transformation.
If ${\mathbf{ITYPE}}\left(i\right)=0$, elements ${\mathbf{TRANS}}\left(1,i\right)$ to ${\mathbf{TRANS}}\left(6,i\right)$ are not referenced.
If ${\mathbf{ITYPE}}\left(i\right)=1$, the translation vector is $\stackrel{\to }{u}=\left(\begin{array}{c}a\\ b\end{array}\right)$, where $a={\mathbf{TRANS}}\left(1,i\right)$ and $b={\mathbf{TRANS}}\left(2,i\right)$, while elements ${\mathbf{TRANS}}\left(3,i\right)$ to ${\mathbf{TRANS}}\left(6,i\right)$ are not referenced.
If ${\mathbf{ITYPE}}\left(i\right)=2$, the user-supplied line is the curve {$\left(x,y\right)\in {ℝ}^{2}$; such that $ax+by+c=0$}, where $a={\mathbf{TRANS}}\left(1,i\right)$, $b={\mathbf{TRANS}}\left(2,i\right)$ and $c={\mathbf{TRANS}}\left(3,i\right)$, while elements ${\mathbf{TRANS}}\left(4,i\right)$ to ${\mathbf{TRANS}}\left(6,i\right)$ are not referenced.
If ${\mathbf{ITYPE}}\left(i\right)=3$, the centre of the rotation is $\left({x}_{0},{y}_{0}\right)$ where ${x}_{0}={\mathbf{TRANS}}\left(1,i\right)$ and ${y}_{0}={\mathbf{TRANS}}\left(2,i\right)$, $\theta ={\mathbf{TRANS}}\left(3,i\right)$ is its angle in degrees, while elements ${\mathbf{TRANS}}\left(4,i\right)$ to ${\mathbf{TRANS}}\left(6,i\right)$ are not referenced.
If ${\mathbf{ITYPE}}\left(i\right)=4$, $a={\mathbf{TRANS}}\left(1,i\right)$ is the scaling coefficient in the $x$-direction, $b={\mathbf{TRANS}}\left(2,i\right)$ is the scaling coefficient in the $y$-direction, and $\left({x}_{0},{y}_{0}\right)$ are the scaling centre coordinates, with ${x}_{0}={\mathbf{TRANS}}\left(3,i\right)$ and ${y}_{0}={\mathbf{TRANS}}\left(4,i\right)$; while elements ${\mathbf{TRANS}}\left(5,i\right)$ to ${\mathbf{TRANS}}\left(6,i\right)$ are not referenced.
If ${\mathbf{ITYPE}}\left(i\right)=10$, the user-supplied analytic affine transformation $Y=A×X+B$ is such that $A={\left({a}_{kl}\right)}_{1\le k,l\le 2}$ and $B={\left({b}_{k}\right)}_{1\le k\le 2}$ where${a}_{kl}={\mathbf{TRANS}}\left(2×\left(k-1\right)+l,i\right)$, and ${b}_{k}={\mathbf{TRANS}}\left(4+k,i\right)$ with $k,l=1,2$.
7:     COORI($2$,NV) – REAL (KIND=nag_wp) arrayInput/Output
On entry: ${\mathbf{COORI}}\left(1,\mathit{i}\right)$ contains the $x$ coordinate of the $\mathit{i}$th vertex of the input mesh, for $\mathit{i}=1,2,\dots ,{\mathbf{NV}}$; while ${\mathbf{COORI}}\left(2,i\right)$ contains the corresponding $y$ coordinate.
On exit: see Section 8.
8:     EDGEI($3$,NEDGE) – INTEGER arrayInput/Output
On entry: the specification of the boundary or interface edges. ${\mathbf{EDGEI}}\left(1,j\right)$ and ${\mathbf{EDGEI}}\left(2,j\right)$ contain the vertex numbers of the two end points of the $j$th boundary edge. ${\mathbf{EDGEI}}\left(3,j\right)$ is a user-supplied tag for the $j$th boundary edge.
Constraint: $1\le {\mathbf{EDGEI}}\left(\mathit{i},\mathit{j}\right)\le {\mathbf{NV}}$ and ${\mathbf{EDGEI}}\left(1,\mathit{j}\right)\ne {\mathbf{EDGEI}}\left(2,\mathit{j}\right)$, for $\mathit{i}=1,2$ and $\mathit{j}=1,2,\dots ,{\mathbf{NEDGE}}$.
On exit: see Section 8.
9:     CONNI($3$,NELT) – INTEGER arrayInput/Output
On entry: the connectivity of the input mesh between triangles and vertices. For each triangle $\mathit{j}$, ${\mathbf{CONNI}}\left(\mathit{i},\mathit{j}\right)$ gives the indices of its three vertices (in anticlockwise order), for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{NELT}}$.
Constraints:
• $1\le {\mathbf{CONNI}}\left(i,j\right)\le {\mathbf{NV}}$;
• ${\mathbf{CONNI}}\left(1,j\right)\ne {\mathbf{CONNI}}\left(2,j\right)$;
• ${\mathbf{CONNI}}\left(1,\mathit{j}\right)\ne {\mathbf{CONNI}}\left(3,\mathit{j}\right)$ and ${\mathbf{CONNI}}\left(2,\mathit{j}\right)\ne {\mathbf{CONNI}}\left(3,\mathit{j}\right)$, for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{NELT}}$.
On exit: see Section 8.
10:   COORO($2$,NV) – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{COORO}}\left(1,\mathit{i}\right)$ will contain the $x$ coordinate of the $\mathit{i}$th vertex of the transformed mesh, for $\mathit{i}=1,2,\dots ,{\mathbf{NV}}$; while ${\mathbf{COORO}}\left(2,i\right)$ will contain the corresponding $y$ coordinate.
11:   EDGEO($3$,NEDGE) – INTEGER arrayOutput
On exit: the specification of the boundary or interface edges of the transformed mesh. If the number of symmetric transformations is even or zero then${\mathbf{EDGEO}}\left(\mathit{i},\mathit{j}\right)={\mathbf{EDGEI}}\left(\mathit{i},\mathit{j}\right)$, for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{NEDGE}}$; otherwise ${\mathbf{EDGEO}}\left(1,\mathit{j}\right)={\mathbf{EDGEI}}\left(2,\mathit{j}\right)$,${\mathbf{EDGEO}}\left(2,\mathit{j}\right)={\mathbf{EDGEI}}\left(1,\mathit{j}\right)$ and ${\mathbf{EDGEO}}\left(3,\mathit{j}\right)={\mathbf{EDGEI}}\left(3,\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{NEDGE}}$.
12:   CONNO($3$,NELT) – INTEGER arrayOutput
On exit: the connectivity of the transformed mesh between triangles and vertices. If the number of symmetric transformations is even or zero then${\mathbf{CONNO}}\left(\mathit{i},\mathit{j}\right)={\mathbf{CONNI}}\left(\mathit{i},\mathit{j}\right)$, for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{NELT}}$; otherwise ${\mathbf{CONNO}}\left(1,\mathit{j}\right)={\mathbf{CONNI}}\left(1,\mathit{j}\right)$, ${\mathbf{CONNO}}\left(2,\mathit{j}\right)={\mathbf{CONNI}}\left(3,\mathit{j}\right)$ and ${\mathbf{CONNO}}\left(3,\mathit{j}\right)={\mathbf{CONNI}}\left(2,\mathit{j}\right)$, for $\mathit{j}=1,2,\dots ,{\mathbf{NELT}}$.
13:   ITRACE – INTEGERInput
On entry: the level of trace information required from D06DAF.
${\mathbf{ITRACE}}\le 0$
No output is generated.
${\mathbf{ITRACE}}\ge 1$
Details of each transformation, the matrix $A$ and the vector $B$ of the final transformation, which is the composition of all the NTRANS transformations, are printed on the current advisory message unit (see X04ABF).
14:   RWORK(LRWORK) – REAL (KIND=nag_wp) arrayWorkspace
15:   LRWORK – INTEGERInput
On entry: the dimension of the array RWORK as declared in the (sub)program from which D06DAF is called.
Constraint: ${\mathbf{LRWORK}}\ge 12×{\mathbf{NTRANS}}$.
16:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{NV}}<3$; or ${\mathbf{NELT}}>2×{\mathbf{NV}}-1$; or ${\mathbf{NEDGE}}<1$; or ${\mathbf{EDGEI}}\left(i,j\right)<1$ or ${\mathbf{EDGEI}}\left(i,j\right)>{\mathbf{NV}}$ for some $i=1,2$ and $j=1,2,\dots ,{\mathbf{NEDGE}}$; or ${\mathbf{EDGEI}}\left(1,j\right)={\mathbf{EDGEI}}\left(2,j\right)$ for some $j=1,2,\dots ,{\mathbf{NEDGE}}$; or ${\mathbf{CONNI}}\left(i,j\right)<1$ or ${\mathbf{CONNI}}\left(i,j\right)>{\mathbf{NV}}$ for some $i=1,2,3$ and $j=1,2,\dots ,{\mathbf{NELT}}$; or ${\mathbf{CONNI}}\left(1,j\right)={\mathbf{CONNI}}\left(2,j\right)$ or ${\mathbf{CONNI}}\left(1,j\right)={\mathbf{CONNI}}\left(3,j\right)$ or ${\mathbf{CONNI}}\left(2,j\right)={\mathbf{CONNI}}\left(3,j\right)$ for some $j=1,2,\dots ,{\mathbf{NELT}}$; or ${\mathbf{NTRANS}}<1$; or ${\mathbf{ITYPE}}\left(i\right)\ne 0$, $1$, $2$, $3$, $4$ or $10$ for some $i=1,2,\dots ,{\mathbf{NTRANS}}$; or ${\mathbf{LRWORK}}<12×{\mathbf{NTRANS}}$.
${\mathbf{IFAIL}}=2$
A serious error has occurred in an internal call to an auxiliary routine. Check the input mesh especially the triangles/vertices and the edges/vertices connectivities as well as the details of each transformations.

Not applicable.

## 8  Further Comments

You may not wish to save the input mesh (COORI, EDGEI and CONNI) and could call D06DAF using the same parameters for the input and the output (transformed) mesh.

## 9  Example

For an example of the use of this utility routine, see Section 9 in D06DBF.