d06 Chapter Contents
d06 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_mesh2d_trans (d06dac)

## 1  Purpose

nag_mesh2d_trans (d06dac) is a utility which performs an affine transformation of a given mesh.

## 2  Specification

 #include #include
 void nag_mesh2d_trans (Integer mode, Integer nv, Integer nedge, Integer nelt, Integer ntrans, const Integer itype[], const double trans[], double coori[], Integer edgei[], Integer conni[], double cooro[], Integer edgeo[], Integer conno[], Integer itrace, const char *outfile, NagError *fail)

## 3  Description

nag_mesh2d_trans (d06dac) 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 function is partly derived from material in the MODULEF package from INRIA (Institut National de Recherche en Informatique et Automatique).

None.

## 5  Arguments

1:     modeIntegerInput
On entry: if ${\mathbf{mode}}=1$, the arguments coori, edgei and conni are overwritten on exit by the output values described in cooro, edgeo and conno respectively. In this case cooro, edgeo and conno are not referenced, and you can save storage space.
If ${\mathbf{mode}}\ne 1$, no such aliasing is assumed.
2:     nvIntegerInput
On entry: the total number of vertices in the input mesh.
Constraint: ${\mathbf{nv}}\ge 3$.
3:     nedgeIntegerInput
On entry: the number of the boundary or interface edges in the input mesh.
Constraint: ${\mathbf{nedge}}\ge 1$.
4:     neltIntegerInput
On entry: the number of triangles in the input mesh.
Constraint: ${\mathbf{nelt}}\le 2×{\mathbf{nv}}-1$.
5:     ntransIntegerInput
On entry: the number of transformations of the input mesh.
Constraint: ${\mathbf{ntrans}}\ge 1$.
6:     itype[ntrans]const IntegerInput
On entry: ${\mathbf{itype}}\left[\mathit{i}-1\right]$, for $\mathit{i}=1,2,\dots ,{\mathbf{ntrans}}$, indicates the type of each transformation as follows:
${\mathbf{itype}}\left[i-1\right]=0$
Identity transformation.
${\mathbf{itype}}\left[i-1\right]=1$
Translation.
${\mathbf{itype}}\left[i-1\right]=2$
Symmetric transformation with respect to a user-supplied line.
${\mathbf{itype}}\left[i-1\right]=3$
Rotation.
${\mathbf{itype}}\left[i-1\right]=4$
Scaling.
${\mathbf{itype}}\left[i-1\right]=10$
User-supplied analytic transformation.
Note that the transformations are applied in the order described in itype.
Constraint: ${\mathbf{itype}}\left[\mathit{i}-1\right]=0$, $1$, $2$, $3$, $4$ or $10$, for $\mathit{i}=1,2,\dots ,{\mathbf{ntrans}}$.
7:     trans[$6×{\mathbf{ntrans}}$]const doubleInput
On entry: the arguments for each transformation. For $i=1,2,\dots ,{\mathbf{ntrans}}$, ${\mathbf{trans}}\left[\left(i-1\right)×6+0\right]$ to ${\mathbf{trans}}\left[\left(i-1\right)×6+5\right]$ contain the arguments of the $i$th transformation.
If ${\mathbf{itype}}\left[i-1\right]=0$, elements ${\mathbf{trans}}\left[\left(i-1\right)×6+0\right]$ to ${\mathbf{trans}}\left[\left(i-1\right)×6+5\right]$ are not referenced.
If ${\mathbf{itype}}\left[i-1\right]=1$, the translation vector is $\stackrel{\to }{u}=\left(\begin{array}{c}a\\ b\end{array}\right)$, where $a={\mathbf{trans}}\left[\left(i-1\right)×6+0\right]$ and $b={\mathbf{trans}}\left[\left(i-1\right)×6+1\right]$, while elements ${\mathbf{trans}}\left[\left(i-1\right)×6+2\right]$ to ${\mathbf{trans}}\left[\left(i-1\right)×6+5\right]$ are not referenced.
If ${\mathbf{itype}}\left[i-1\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[\left(i-1\right)×6+0\right]$, $b={\mathbf{trans}}\left[\left(i-1\right)×6+1\right]$ and $c={\mathbf{trans}}\left[\left(i-1\right)×6+2\right]$, while elements ${\mathbf{trans}}\left[\left(i-1\right)×6+3\right]$ to ${\mathbf{trans}}\left[\left(i-1\right)×6+5\right]$ are not referenced.
If ${\mathbf{itype}}\left[i-1\right]=3$, the centre of the rotation is $\left({x}_{0},{y}_{0}\right)$ where ${x}_{0}={\mathbf{trans}}\left[\left(i-1\right)×6+0\right]$ and ${y}_{0}={\mathbf{trans}}\left[\left(i-1\right)×6+1\right]$, $\theta ={\mathbf{trans}}\left[\left(i-1\right)×6+2\right]$ is its angle in degrees, while elements ${\mathbf{trans}}\left[\left(i-1\right)×6+3\right]$ to ${\mathbf{trans}}\left[\left(i-1\right)×6+5\right]$ are not referenced.
If ${\mathbf{itype}}\left[i-1\right]=4$, $a={\mathbf{trans}}\left[\left(i-1\right)×6+0\right]$ is the scaling coefficient in the $x$-direction, $b={\mathbf{trans}}\left[\left(i-1\right)×6+1\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[\left(i-1\right)×6+2\right]$ and ${y}_{0}={\mathbf{trans}}\left[\left(i-1\right)×6+3\right]$; while elements ${\mathbf{trans}}\left[\left(i-1\right)×6+4\right]$ to ${\mathbf{trans}}\left[\left(i-1\right)×6+5\right]$ are not referenced.
If ${\mathbf{itype}}\left[i-1\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[\left(i-1\right)×6+2×\left(k-1\right)+l-1\right]$, and ${b}_{k}={\mathbf{trans}}\left[\left(i-1\right)×6+4+k-1\right]$ with $k,l=1,2$.
8:     coori[$2×{\mathbf{nv}}$]doubleInput/Output
On entry: ${\mathbf{coori}}\left[\left(\mathit{i}-1\right)×2+0\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[\left(i-1\right)×2+1\right]$ contains the corresponding $y$ coordinate.
On exit: if ${\mathbf{mode}}=1$, coori is assumed to hold the values of cooro.
9:     edgei[$3×{\mathbf{nedge}}$]IntegerInput/Output
On entry: the specification of the boundary or interface edges. ${\mathbf{edgei}}\left[\left(j-1\right)×3+0\right]$ and ${\mathbf{edgei}}\left[\left(j-1\right)×3+1\right]$ contain the vertex numbers of the two end points of the $j$th boundary edge. ${\mathbf{edgei}}\left[\left(j-1\right)×3+2\right]$ is a user-supplied tag for the $j$th boundary edge. Note that the edge vertices are numbered from $1$ to nv.
Constraint: $1\le {\mathbf{edgei}}\left[\left(\mathit{j}-1\right)×3+\mathit{i}-1\right]\le {\mathbf{nv}}$ and ${\mathbf{edgei}}\left[\left(\mathit{j}-1\right)×3+0\right]\ne {\mathbf{edgei}}\left[\left(\mathit{j}-1\right)×3+1\right]$, for $\mathit{i}=1,2$ and $\mathit{j}=1,2,\dots ,{\mathbf{nedge}}$.
On exit: if ${\mathbf{mode}}=1$, edgei holds the output values described in edgeo.
10:   conni[$3×{\mathbf{nelt}}$]IntegerInput/Output
On entry: the connectivity of the input mesh between triangles and vertices. For each triangle $\mathit{j}$, ${\mathbf{conni}}\left[\left(\mathit{j}-1\right)×3+\mathit{i}-1\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}}$. Note that the mesh vertices are numbered from $1$ to nv.
Constraints:
• $1\le {\mathbf{conni}}\left[\left(j-1\right)×3+i-1\right]\le {\mathbf{nv}}$;
• ${\mathbf{conni}}\left[\left(j-1\right)×3+0\right]\ne {\mathbf{conni}}\left[\left(j-1\right)×3+1\right]$;
• ${\mathbf{conni}}\left[\left(\mathit{j}-1\right)×3+0\right]\ne {\mathbf{conni}}\left[\left(\mathit{j}-1\right)×3+2\right]$ and ${\mathbf{conni}}\left[\left(\mathit{j}-1\right)×3+1\right]\ne {\mathbf{conni}}\left[\left(\mathit{j}-1\right)×3+2\right]$, for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{nelt}}$.
On exit: if ${\mathbf{mode}}=1$, conni holds the output values described in conno.
11:   cooro[$\mathit{dim}$]doubleOutput
Note: the dimension, dim, of the array cooro must be at least
• $2×{\mathbf{nv}}$ when ${\mathbf{mode}}\ne 1$;
• $1$ otherwise.
On exit: ${\mathbf{cooro}}\left[0\right]\left[\mathit{i}-1\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[1\right]\left[i-1\right]$ will contain the corresponding $y$ coordinate. If ${\mathbf{mode}}=1$ the results are instead overwritten in coori.
12:   edgeo[$\mathit{dim}$]IntegerOutput
Note: the dimension, dim, of the array edgeo must be at least
• $3×{\mathbf{nedge}}$ when ${\mathbf{mode}}\ne 1$;
• $1$ otherwise.
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}-1\right]\left[\mathit{j}-1\right]={\mathbf{edgei}}\left[\left(\mathit{j}-1\right)×3+\mathit{i}-1\right]$, for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{nedge}}$; otherwise ${\mathbf{edgeo}}\left[0\right]\left[\mathit{j}-1\right]={\mathbf{edgei}}\left[\left(\mathit{j}-1\right)×3+1\right]$,${\mathbf{edgeo}}\left[1\right]\left[\mathit{j}-1\right]={\mathbf{edgei}}\left[\left(\mathit{j}-1\right)×3+0\right]$ and ${\mathbf{edgeo}}\left[2\right]\left[\mathit{j}-1\right]={\mathbf{edgei}}\left[\left(\mathit{j}-1\right)×3+2\right]$, for $\mathit{j}=1,2,\dots ,{\mathbf{nedge}}$. If ${\mathbf{mode}}=1$ the results are overwritten in edgei.
13:   conno[$\mathit{dim}$]IntegerOutput
Note: the dimension, dim, of the array conno must be at least
• $3×{\mathbf{nelt}}$ when ${\mathbf{mode}}\ne 1$;
• $1$ otherwise.
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}-1\right]\left[\mathit{j}-1\right]={\mathbf{conni}}\left[\left(\mathit{j}-1\right)×3+\mathit{i}-1\right]$, for $\mathit{i}=1,2,3$ and $\mathit{j}=1,2,\dots ,{\mathbf{nelt}}$; otherwise ${\mathbf{conno}}\left[0\right]\left[\mathit{j}-1\right]={\mathbf{conni}}\left[\left(\mathit{j}-1\right)×3+0\right]$, ${\mathbf{conno}}\left[1\right]\left[\mathit{j}-1\right]={\mathbf{conni}}\left[\left(\mathit{j}-1\right)×3+2\right]$ and ${\mathbf{conno}}\left[2\right]\left[\mathit{j}-1\right]={\mathbf{conni}}\left[\left(\mathit{j}-1\right)×3+1\right]$, for $\mathit{j}=1,2,\dots ,{\mathbf{nelt}}$. Note that the mesh vertices are numbered from $1$ to nv. If ${\mathbf{mode}}=1$ the results are instead overwritten in conni.
14:   itraceIntegerInput
On entry: the level of trace information required from nag_mesh2d_trans (d06dac).
${\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.
15:   outfileconst char *Input
On entry: the name of a file to which diagnostic output will be directed. If outfile is NULL the diagnostic output will be directed to standard output.
16:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{nedge}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nedge}}\ge 1$.
On entry, ${\mathbf{ntrans}}=〈\mathit{\text{value}}〉$
Constraint: ${\mathbf{ntrans}}>0$.
On entry, ${\mathbf{ntrans}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ntrans}}\ge 1$.
On entry, ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nv}}\ge 3$.
NE_INT_2
On entry, ${\mathbf{itype}}\left[i-1\right]=〈\mathit{\text{value}}〉$ and $i=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{itype}}\left[i-1\right]=0$, $1$, $2$, $3$, $4$ or $10$.
On entry, ${\mathbf{nelt}}=〈\mathit{\text{value}}〉$ and ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{nelt}}\le 2×{\mathbf{nv}}-1$.
On entry, the endpoints of the edge $j$ have the same index $i$: $j=〈\mathit{\text{value}}〉$ and $i=〈\mathit{\text{value}}〉$.
On entry, vertices $1$ and $2$ of the triangle $k$ have the same index $i$: $k=〈\mathit{\text{value}}〉$ and $i=〈\mathit{\text{value}}〉$.
On entry, vertices $1$ and $3$ of the triangle $k$ have the same index $i$: $k=〈\mathit{\text{value}}〉$ and $i=〈\mathit{\text{value}}〉$.
On entry, vertices $2$ and $3$ of the triangle $k$ have the same index $i$: $k=〈\mathit{\text{value}}〉$ and $i=〈\mathit{\text{value}}〉$.
NE_INT_4
On entry, ${\mathbf{CONNI}}\left(i,j\right)=〈\mathit{\text{value}}〉$, $i=〈\mathit{\text{value}}〉$, $j=〈\mathit{\text{value}}〉$ and ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{CONNI}}\left(i,j\right)\ge 1$ and ${\mathbf{CONNI}}\left(i,j\right)\le {\mathbf{nv}}$, where ${\mathbf{CONNI}}\left(i,j\right)$ denotes ${\mathbf{conni}}\left[\left(j-1\right)×3+i-1\right]$.
On entry, ${\mathbf{EDGEI}}\left(i,j\right)=〈\mathit{\text{value}}〉$, $i=〈\mathit{\text{value}}〉$, $j=〈\mathit{\text{value}}〉$ and ${\mathbf{nv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{EDGEI}}\left(i,j\right)\ge 1$ and ${\mathbf{EDGEI}}\left(i,j\right)\le {\mathbf{nv}}$, where ${\mathbf{EDGEI}}\left(i,j\right)$ denotes ${\mathbf{edgei}}\left[\left(j-1\right)×3+i-1\right]$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
A serious error has occurred in an internal call to an auxiliary function. Check the input mesh especially the connectivities and the details of each transformations.
NE_NOT_CLOSE_FILE
Cannot close file $〈\mathit{\text{value}}〉$.
NE_NOT_WRITE_FILE
Cannot open file $〈\mathit{\text{value}}〉$ for writing.

Not applicable.