hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_mesh_2d_transform_affine (d06da)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_mesh_2d_transform_affine (d06da) is a utility which performs an affine transformation of a given mesh.

Syntax

[coori, edgei, conni, cooro, edgeo, conno, ifail] = d06da(itype, trans, coori, edgei, conni, itrace, 'nv', nv, 'nedge', nedge, 'nelt', nelt, 'ntrans', ntrans)
[coori, edgei, conni, cooro, edgeo, conno, ifail] = nag_mesh_2d_transform_affine(itype, trans, coori, edgei, conni, itrace, 'nv', nv, 'nedge', nedge, 'nelt', nelt, 'ntrans', ntrans)

Description

nag_mesh_2d_transform_affine (d06da) 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).

References

None.

Parameters

Compulsory Input Parameters

1:     itypentrans int64int32nag_int array
itypei, for i=1,2,,ntrans, indicates the type of each transformation as follows:
itypei=0
Identity transformation.
itypei=1
Translation.
itypei=2
Symmetric transformation with respect to a user-supplied line.
itypei=3
Rotation.
itypei=4
Scaling.
itypei=10
User-supplied analytic transformation.
Note that the transformations are applied in the order described in itype.
Constraint: itypei=0, 1, 2, 3, 4 or 10, for i=1,2,,ntrans.
2:     trans6ntrans – double array
The arguments for each transformation. For i=1,2,,ntrans, trans1i to trans6i contain the arguments of the ith transformation.
If itypei=0, elements trans1i to trans6i are not referenced.
If itypei=1, the translation vector is u= a b , where a=trans1i and b=trans2i, while elements trans3i to trans6i are not referenced.
If itypei=2, the user-supplied line is the curve {x,y2; such that ax+by+c=0}, where a=trans1i, b=trans2i and c=trans3i, while elements trans4i to trans6i are not referenced.
If itypei=3, the centre of the rotation is x0,y0 where x0=trans1i and y0=trans2i, θ=trans3i is its angle in degrees, while elements trans4i to trans6i are not referenced.
If itypei=4, a=trans1i is the scaling coefficient in the x-direction, b=trans2i is the scaling coefficient in the y-direction, and x0,y0 are the scaling centre coordinates, with x0=trans3i and y0=trans4i; while elements trans5i to trans6i are not referenced.
If itypei=10, the user-supplied analytic affine transformation Y=A×X+B is such that A=akl1k,l2 and B=bk1k2 whereakl=trans2×k-1+li, and bk=trans4+ki with k,l=1,2.
3:     coori2nv – double array
coori1i contains the x coordinate of the ith vertex of the input mesh, for i=1,2,,nv; while coori2i contains the corresponding y coordinate.
4:     edgei3nedge int64int32nag_int array
The specification of the boundary or interface edges. edgei1j and edgei2j contain the vertex numbers of the two end points of the jth boundary edge. edgei3j is a user-supplied tag for the jth boundary edge.
Constraint: 1edgeiijnv and edgei1jedgei2j, for i=1,2 and j=1,2,,nedge.
5:     conni3nelt int64int32nag_int array
The connectivity of the input mesh between triangles and vertices. For each triangle j, conniij gives the indices of its three vertices (in anticlockwise order), for i=1,2,3 and j=1,2,,nelt.
Constraints:
  • 1conniijnv;
  • conni1jconni2j;
  • conni1jconni3j and conni2jconni3j, for i=1,2,3 and j=1,2,,nelt.
6:     itrace int64int32nag_int scalar
The level of trace information required from nag_mesh_2d_transform_affine (d06da).
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 on the current advisory message unit (see nag_file_set_unit_advisory (x04ab)).

Optional Input Parameters

1:     nv int64int32nag_int scalar
Default: the dimension of the array coori.
The total number of vertices in the input mesh.
Constraint: nv3.
2:     nedge int64int32nag_int scalar
Default: the dimension of the array edgei.
The number of the boundary or interface edges in the input mesh.
Constraint: nedge1.
3:     nelt int64int32nag_int scalar
Default: the dimension of the array conni.
The number of triangles in the input mesh.
Constraint: nelt2×nv-1.
4:     ntrans int64int32nag_int scalar
Default: the dimension of the arrays itype, trans. (An error is raised if these dimensions are not equal.)
The number of transformations of the input mesh.
Constraint: ntrans1.

Output Parameters

1:     coori2nv – double array
2:     edgei3nedge int64int32nag_int array
3:     conni3nelt int64int32nag_int array
4:     cooro2nv – double array
cooro1i will contain the x coordinate of the ith vertex of the transformed mesh, for i=1,2,,nv; while cooro2i will contain the corresponding y coordinate.
5:     edgeo3nedge int64int32nag_int array
The specification of the boundary or interface edges of the transformed mesh. If the number of symmetric transformations is even or zero thenedgeoij=edgeiij, for i=1,2,3 and j=1,2,,nedge; otherwise edgeo1j=edgei2j,edgeo2j=edgei1j and edgeo3j=edgei3j, for j=1,2,,nedge.
6:     conno3nelt int64int32nag_int array
The connectivity of the transformed mesh between triangles and vertices. If the number of symmetric transformations is even or zero thenconnoij=conniij, for i=1,2,3 and j=1,2,,nelt; otherwise conno1j=conni1j, conno2j=conni3j and conno3j=conni2j, for j=1,2,,nelt.
7:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
On entry,nv<3;
ornelt>2×nv-1;
ornedge<1;
oredgeiij<1 or edgeiij>nv for some i=1,2 and j=1,2,,nedge;
oredgei1j=edgei2j for some j=1,2,,nedge;
orconniij<1 or conniij>nv for some i=1,2,3 and j=1,2,,nelt;
orconni1j=conni2j or conni1j=conni3j or
conni2j=conni3j for some j=1,2,,nelt;
orntrans<1;
oritypei0, 1, 2, 3, 4 or 10 for some i=1,2,,ntrans;
orlrwork<12×ntrans.
   ifail=2
A serious error has occurred in an internal call to an auxiliary function. Check the input mesh especially the triangles/vertices and the edges/vertices connectivities as well as the details of each transformations.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Not applicable.

Further Comments

You may not wish to save the input mesh (coori, edgei and conni) and could call nag_mesh_2d_transform_affine (d06da) using the same arguments for the input and the output (transformed) mesh.

Example

For an example of the use of this utility function, see Example in nag_mesh_2d_join (d06db).
function d06da_example


fprintf('d06da example results\n\n');

coor1 = zeros(2,400);
for j = 1:20
  for i = 1:20
    coor1(1,(j-1)*20+i) = (i-1)/19;
    coor1(2,(j-1)*20+i) = (j-1)/19;
  end
end
edge1 = ones(3, 76, 'int64');
edge1(1, 1:76) = int64([1:19,20*(1:19),401-(1:19),401-20*(1:19)]);
edge1(2, 1:76) = int64([2:19,20*(1:19),401-(1:19),401-20*(1:19),1]);
conn1 = zeros(3, 722, 'int64');
ind = -1;
for i=1:379
  if (rem(i, 20) ~= 0)
    ind = ind+2;
    conn1(1, ind)   = int64(i);
    conn1(1, ind+1) = int64(i);
    conn1(2, ind)   = int64(i+1);
    conn1(2, ind+1) = int64(i+21);
    conn1(3, ind)   = int64(i+21);
    conn1(3, ind+1) = int64(i+20);
  end
end
reft1 = ones(722, 1, 'int64');
reft2 = reft1;
reft2(:) = int64(2);
itype = [int64(1)];
itrace = int64(1);

% Transform the first domain to obtain an overlapping second domain
trans = [15/19; 17/19; 0; 0; 0; 0];
[coor1, edge1, conn1, coor2, edge2, conn2, ifail] = ...
d06da( ...
       itype, trans, coor1, edge1, conn1, itrace);

% Restitch the meshes
[nv3, nelt3, nedge3, coor3, edge3, conn3, reft3, ifail] = ...
d06db( ...
       coor1, edge1, conn1, reft1, coor2, edge2, conn2, reft2, itrace);

% Plot the result
fig1 = figure;
triplot(transpose(double(conn3(:,1:nelt3))), coor3(1,:), coor3(2,:));
title ('Interior mesh of the two overlapping squares geometry');

% Now consider a partitioned second domain
trans = [1; 0; 0; 0; 0; 0];
[coor1, edge1, conn1, coor2, edge2, conn2, ifail] = ...
d06da( ...
       itype, trans, coor1, edge1, conn1, itrace);

% Restitch the meshes
[nv3, nelt3, nedge3, coor3, edge3, conn3, reft3, ifail] = ...
d06db( ...
       coor1, edge1, conn1, reft1, coor2, edge2, conn2, reft2, itrace);


% Plot the result
fig2 = figure;
triplot(transpose(double(conn3(:,1:nelt3))), coor3(1,:), coor3(2,:));
title ('Interior mesh of the two partitioned squares geometry');


d06da example results


 Transformation   1: translation
  translation vector:  0.7895      0.8947

 Final transformation matrix y = A*x + b:
    1.000       0.000         0.7895
    0.000       1.000         0.8947

 Transformation   1: translation
  translation vector:   1.000       0.000

 Final transformation matrix y = A*x + b:
    1.000       0.000          1.000
    0.000       1.000          0.000
d06da_fig1.png
d06da_fig2.png

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015