rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
aff_trafo_loc2glob.m
1 function [C, G] = aff_trafo_loc2glob(x0, y0)
2 %function [C, G] = aff_trafo_loc2glob(x0, y0)
3 % function giving the coefficients for the affine transformation
4 % from reference/local triangle to the original/global one.
5 %
6 % In detail, this implements a transformation of the type
7 % ``T^{-1}_{i,aff}(x;\mu) = C^{-1}_{i,aff}(\mu) + \sum_{j=1,2} G^{k,-1}_{ij}(\mu) x_j \qquad i=1,2``
8 %
9 % The transformation is calculated for the standard triangle:
10 %
11 % @verbatim
12 % triangle: (0,1) |\ /| (x0(3),y0(3))
13 % | \ ---T---> / |
14 % (0,0) |__\ (1,0) (x0(1),y0(1)) /__| (x0(2),y0(2))
15 % @endverbatim
16 %
17 % Parameters:
18 % x0: vector of size '3 x 1' holding x values of the original/global triangle
19 % y0: vector of size '3 x 1' holding y values of the original/global triangle
20 %
21 % Return values:
22 % C: matrix of size '2 x 1' with entries 'C=[c1; c2]'
23 % G: matrix of size '2 x 2' with entries 'G=[g11, g12; g21, g22]'
24 %
25 % See also aff_trafo_glob2loc() which gives the transformation in the other
26 % direction (global to local)
27 
28 % Oliver Zeeb, 01.02.11
29 
30 
31 %standard triangle
32 x1 = 0;
33 y1 = 0;
34 x2 = 1;
35 y2 = 0;
36 x3 = 0;
37 y3 = 1;
38 
39 
40 
41 %matrices for transformation:
42 B_aff = [1, 0, x1, y1, 0, 0; ...
43  0, 1, 0, 0, x1, y1; ...
44  1, 0, x2, y2, 0, 0; ...
45  0, 1, 0, 0, x2, y2; ...
46  1, 0, x3, y3, 0, 0; ...
47  0, 1, 0, 0, x3, y3];
48 
49 V_aff = [x0(1); y0(1); x0(2); y0(2); x0(3); y0(3)];
50 
51 coef_vec = B_aff \ V_aff;
52 
53 C = [coef_vec(1); coef_vec(2)];
54 G = [coef_vec(3), coef_vec(4); coef_vec(5), coef_vec(6)];
55 % c1 = coef_vec(1);
56 % c2 = coef_vec(2);
57 % g11 = coef_vec(3);
58 % g12 = coef_vec(4);
59 % g21 = coef_vec(5);
60 % g22 = coef_vec(6);