nag_mesh2d_trans (d06dac) (PDF version)
d06 Chapter Contents
d06 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_mesh2d_trans (d06dac)

+ Contents

    1  Purpose
    7  Accuracy
    9  Example

1  Purpose

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

2  Specification

#include <nag.h>
#include <nagd06.h>
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
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).

4  References

None.

5  Arguments

1:     modeIntegerInput
On entry: if 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 mode1, no such aliasing is assumed.
2:     nvIntegerInput
On entry: the total number of vertices in the input mesh.
Constraint: nv3.
3:     nedgeIntegerInput
On entry: the number of the boundary or interface edges in the input mesh.
Constraint: nedge1.
4:     neltIntegerInput
On entry: the number of triangles in the input mesh.
Constraint: nelt2×nv-1.
5:     ntransIntegerInput
On entry: the number of transformations of the input mesh.
Constraint: ntrans1.
6:     itype[ntrans]const IntegerInput
On entry: itype[i-1], for i=1,2,,ntrans, indicates the type of each transformation as follows:
itype[i-1]=0
Identity transformation.
itype[i-1]=1
Translation.
itype[i-1]=2
Symmetric transformation with respect to a user-supplied line.
itype[i-1]=3
Rotation.
itype[i-1]=4
Scaling.
itype[i-1]=10
User-supplied analytic transformation.
Note that the transformations are applied in the order described in itype.
Constraint: itype[i-1]=0, 1, 2, 3, 4 or 10, for i=1,2,,ntrans.
7:     trans[6×ntrans]const doubleInput
On entry: the arguments for each transformation. For i=1,2,,ntrans, trans[i-1×6+0] to trans[i-1×6+5] contain the arguments of the ith transformation.
If itype[i-1]=0, elements trans[i-1×6+0] to trans[i-1×6+5] are not referenced.
If itype[i-1]=1, the translation vector is u= a b , where a=trans[i-1×6+0] and b=trans[i-1×6+1], while elements trans[i-1×6+2] to trans[i-1×6+5] are not referenced.
If itype[i-1]=2, the user-supplied line is the curve {x,y2; such that ax+by+c=0}, where a=trans[i-1×6+0], b=trans[i-1×6+1] and c=trans[i-1×6+2], while elements trans[i-1×6+3] to trans[i-1×6+5] are not referenced.
If itype[i-1]=3, the centre of the rotation is x0,y0 where x0=trans[i-1×6+0] and y0=trans[i-1×6+1], θ=trans[i-1×6+2] is its angle in degrees, while elements trans[i-1×6+3] to trans[i-1×6+5] are not referenced.
If itype[i-1]=4, a=trans[i-1×6+0] is the scaling coefficient in the x-direction, b=trans[i-1×6+1] is the scaling coefficient in the y-direction, and x0,y0 are the scaling centre coordinates, with x0=trans[i-1×6+2] and y0=trans[i-1×6+3]; while elements trans[i-1×6+4] to trans[i-1×6+5] are not referenced.
If itype[i-1]=10, the user-supplied analytic affine transformation Y=A×X+B is such that A=akl1k,l2 and B=bk1k2 whereakl=trans[i-1×6+2×k-1+l-1], and bk=trans[i-1×6+4+k-1] with k,l=1,2.
8:     coori[2×nv]doubleInput/Output
On entry: coori[i-1×2+0] contains the x coordinate of the ith vertex of the input mesh, for i=1,2,,nv; while coori[i-1×2+1] contains the corresponding y coordinate.
On exit: if mode=1, coori is assumed to hold the values of cooro.
9:     edgei[3×nedge]IntegerInput/Output
On entry: the specification of the boundary or interface edges. edgei[j-1×3+0] and edgei[j-1×3+1] contain the vertex numbers of the two end points of the jth boundary edge. edgei[j-1×3+2] is a user-supplied tag for the jth boundary edge. Note that the edge vertices are numbered from 1 to nv.
Constraint: 1edgei[j-1×3+i-1]nv and edgei[j-1×3+0]edgei[j-1×3+1], for i=1,2 and j=1,2,,nedge.
On exit: if mode=1, edgei holds the output values described in edgeo.
10:   conni[3×nelt]IntegerInput/Output
On entry: the connectivity of the input mesh between triangles and vertices. For each triangle j, conni[j-1×3+i-1] gives the indices of its three vertices (in anticlockwise order), for i=1,2,3 and j=1,2,,nelt. Note that the mesh vertices are numbered from 1 to nv.
Constraints:
  • 1conni[j-1×3+i-1]nv;
  • conni[j-1×3+0]conni[j-1×3+1];
  • conni[j-1×3+0]conni[j-1×3+2] and conni[j-1×3+1]conni[j-1×3+2], for i=1,2,3 and j=1,2,,nelt.
On exit: if mode=1, conni holds the output values described in conno.
11:   cooro[dim]doubleOutput
Note: the dimension, dim, of the array cooro must be at least
  • 2×nv when mode1;
  • 1 otherwise.
On exit: cooro[0][i-1] will contain the x coordinate of the ith vertex of the transformed mesh, for i=1,2,,nv; while cooro[1][i-1] will contain the corresponding y coordinate. If mode=1 the results are instead overwritten in coori.
12:   edgeo[dim]IntegerOutput
Note: the dimension, dim, of the array edgeo must be at least
  • 3×nedge when mode1;
  • 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 thenedgeo[i-1][j-1]=edgei[j-1×3+i-1], for i=1,2,3 and j=1,2,,nedge; otherwise edgeo[0][j-1]=edgei[j-1×3+1],edgeo[1][j-1]=edgei[j-1×3+0] and edgeo[2][j-1]=edgei[j-1×3+2], for j=1,2,,nedge. If mode=1 the results are overwritten in edgei.
13:   conno[dim]IntegerOutput
Note: the dimension, dim, of the array conno must be at least
  • 3×nelt when mode1;
  • 1 otherwise.
On exit: the connectivity of the transformed mesh between triangles and vertices. If the number of symmetric transformations is even or zero thenconno[i-1][j-1]=conni[j-1×3+i-1], for i=1,2,3 and j=1,2,,nelt; otherwise conno[0][j-1]=conni[j-1×3+0], conno[1][j-1]=conni[j-1×3+2] and conno[2][j-1]=conni[j-1×3+1], for j=1,2,,nelt. Note that the mesh vertices are numbered from 1 to nv. If mode=1 the results are instead overwritten in conni.
14:   itraceIntegerInput
On entry: the level of trace information required from nag_mesh2d_trans (d06dac).
itrace0
No output is generated.
itrace1
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.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, nedge=value.
Constraint: nedge1.
On entry, ntrans=value
Constraint: ntrans>0.
On entry, ntrans=value.
Constraint: ntrans1.
On entry, nv=value.
Constraint: nv3.
NE_INT_2
On entry, itype[i-1]=value and i=value.
Constraint: itype[i-1]=0, 1, 2, 3, 4 or 10.
On entry, nelt=value and nv=value.
Constraint: nelt2×nv-1.
On entry, the endpoints of the edge j have the same index i: j=value and i=value.
On entry, vertices 1 and 2 of the triangle k have the same index i: k=value and i=value.
On entry, vertices 1 and 3 of the triangle k have the same index i: k=value and i=value.
On entry, vertices 2 and 3 of the triangle k have the same index i: k=value and i=value.
NE_INT_4
On entry, CONNIi,j=value, i=value, j=value and nv=value.
Constraint: CONNIi,j1 and CONNIi,jnv, where CONNIi,j denotes conni[j-1×3+i-1].
On entry, EDGEIi,j=value, i=value, j=value and nv=value.
Constraint: EDGEIi,j1 and EDGEIi,jnv, where EDGEIi,j denotes edgei[j-1×3+i-1].
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 value.
NE_NOT_WRITE_FILE
Cannot open file value for writing.

7  Accuracy

Not applicable.

8  Further Comments

None.

9  Example

For an example of the use of this utility function, see Section 9 in nag_mesh2d_join (d06dbc).

nag_mesh2d_trans (d06dac) (PDF version)
d06 Chapter Contents
d06 Chapter Introduction
NAG C Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012